Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

OracleBFile.SetFileName Method

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

Namespace: System.Data.OracleClient
Assembly: System.Data.OracleClient (in system.data.oracleclient.dll)

public void SetFileName (
	string directory,
	string file
)
public void SetFileName (
	String directory, 
	String file
)
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.

Exception typeCondition

InvalidOperationException

The operation must be within a transaction.

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.

Once you retrieve the DirectoryName or FileName property, they are cached in the OracleBFile object and are unaffected by any cloned OracleBFile objects' calls to SetFileName, or by any changes to the BFILE in the database. In other words, they might not represent the actual values of the BFILE object in the server.

Furthermore, retrieving either property (DirectoryName or FileName) causes both property values to be retrieved from the server and cached in the OracleBFile object.

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 dataReader = command.ExecuteReader();
using (dataReader) {
    if (dataReader.Read()) {
        OracleBFile BFile = dataReader.GetOracleBFile(1);
        using (BFile) {
            BFile.Seek(0, SeekOrigin.Begin);
            BFile.Read(buffer, 0, 100);
            command.Transaction = connection.BeginTransaction();
            BFile.SetFileName("TESTDIR", "File1.jpg");
            BFile.Read(buffer, 0, 100);
        
    

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.