OracleBFile.SetFileName(String, String) 方法

定义

OracleBFile 对象绑定到操作系统中的其他文件。Binds the OracleBFile object to a different file in the operating system.

public:
 void SetFileName(System::String ^ directory, System::String ^ file);
public void SetFileName (string directory, string file);
member this.SetFileName : string * string -> unit
Public Sub SetFileName (directory As String, file As String)

参数

directory
String

包含物理文件的目录对象的别名。The alias of the directory object that contains a physical file.

file
String

操作系统中文件的名称。The name of the file in the operating system.

例外

该操作必须在事务中。The operation must be within a transaction.

注解

SetFileName操作必须在事务内才能成功。The SetFileName operation must be within a transaction to succeed. 只需调用 SetFileName BFILE ,就会将 OracleBFile 对象与另一个文件相关联,但不会更新 Oracle 表。Simply calling SetFileName on a BFILE associates the OracleBFile object with a different file, but does not update the Oracle table. 若要在调用后更新 Oracle 表 SetFileName ,必须调用的 Update 方法, OracleDataAdapter 然后提交事务。To update the Oracle table after calling SetFileName, you must call the Update method of the OracleDataAdapter and then commit the transaction.

检索 DirectoryNameFileName 属性后,它们将缓存在对象中, OracleBFile 并不受任何克隆对象的 OracleBFile 调用 SetFileName 或数据库中的任何更改的影响 BFILEOnce 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. 换言之,它们可能不表示 BFILE 服务器中对象的实际值。In other words, they might not represent the actual values of the BFILE object in the server.

此外,检索任一属性( DirectoryNameFileName )都将导致从服务器中检索这两个属性值并将其缓存在 OracleBFile 对象中。Furthermore, retrieving either property (DirectoryName or FileName) causes both property values to be retrieved from the server and cached in the OracleBFile object.

下面的 c # 示例在 Oracle 表中假定此架构:The following C# example assumes this schema in an Oracle table:

(col1 number, col2 BFILE)  

该示例演示如何使用 SetFileName ReadSeek 方法来访问 OracleBFile 对象。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);  
        }  
    }  
}  

适用于