Export (0) Print
Expand All

OracleBFile.SetFileName Method

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Binds the OracleBFile object to a different file in the operating system.

[Visual Basic]
Public Sub SetFileName( _
   ByVal directory As String, _
   ByVal file As String _
)
[C#]
public void SetFileName(
 string directory,
 string file
);
[C++]
public: void SetFileName(
 String* directory,
 String* file
);
[JScript]
public function SetFileName(
   directory : String,
 file : String
);

Parameters

directory
The alias of the directory object that contains a physical file.
file
The name of the file in the operating system.

Exceptions

Exception Type Condition
InvalidOperationException The operation be within a transaction.

Remarks

The SetFileName operation must be within a transaction to succeed. Simply calling SetFileName on a BFILE associates the OracleBFile object with a different file, but does not update the Oracle table. To update the Oracle table after calling SetFileName, you must call the Update method of the OracleDataAdapter and then commit the transaction.

An OracleBFile object has an underlying Oracle LOB locator. When you clone an OracleBFile, the provider does not create a new LOB locator, but shares references to the original LOB locator between the clones. When you call SetFileName on a clone, there is only one LOB locator in which the file name is changed. Therefore, all clones will reflect the new file name. However, all clones of the OracleBFile maintain their previous Position settings, and each clone may be reading from a different location. When a SetFileName operation is performed on a clone, only the clone that has SetFileName called on it has its Position reset to zero. Any other clones retain their current Position settings.

The following C# example assumes this schema in an Oracle table:

(col1 number, col2 BFILE)

The example demonstrates using the SetFileName, Read and Seek methods to access an OracleBFile object.

byte[] buffer = new byte[100];
OracleDataReader myReader = myCommand.ExecuteReader();
using (myReader) {
    if (myReader.Read()) {
        OracleBFile myBFile = myReader.GetOracleBFile(1);
        using (myBFile) {
            myBFile.Seek(0, SeekOrigin.Begin);
            myBFile.Read(buffer, 0, 100);
            myCommand.Transaction = myConnection.BeginTransaction();
            myBFile.SetFileName("MYDIR", "MyFile2.jpg");
            myBFile.Read(buffer, 0, 100);
        }
    }
}

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

OracleBFile Class | OracleBFile Members | System.Data.OracleClient Namespace

Show:
© 2015 Microsoft