OracleBFile.SetFileName(String, String) Método
Definição
Associa o objeto OracleBFile a um arquivo diferente no sistema operacional.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)
Parâmetros
- directory
- String
O alias do objeto de diretório que contém um arquivo físico.The alias of the directory object that contains a physical file.
- file
- String
O nome do arquivo no sistema operacional.The name of the file in the operating system.
Exceções
A operação deve ser executada dentro de uma transação.The operation must be within a transaction.
Comentários
A SetFileName operação deve estar dentro de uma transação para ter sucesso.The SetFileName operation must be within a transaction to succeed. Simplesmente chamar SetFileName em um BFILE associa o OracleBFile objeto a um arquivo diferente, mas não atualiza a tabela do Oracle.Simply calling SetFileName on a BFILE associates the OracleBFile object with a different file, but does not update the Oracle table. Para atualizar a tabela do Oracle após chamar SetFileName , você deve chamar o Update método do OracleDataAdapter e, em seguida, confirmar a transação.To update the Oracle table after calling SetFileName, you must call the Update method of the OracleDataAdapter and then commit the transaction.
Depois de recuperar a DirectoryName FileName propriedade ou, elas são armazenadas em cache no OracleBFile objeto e não são afetadas por chamadas de objetos clonados OracleBFile para SetFileName ou por qualquer alteração no banco de BFILE dados.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. Em outras palavras, eles podem não representar os valores reais do BFILE objeto no servidor.In other words, they might not represent the actual values of the BFILE object in the server.
Além disso, a recuperação de qualquer propriedade ( DirectoryName ou FileName ) faz com que os dois valores de propriedade sejam recuperados do servidor e armazenados em cache no OracleBFile objeto.Furthermore, retrieving either property (DirectoryName or FileName) causes both property values to be retrieved from the server and cached in the OracleBFile object.
O exemplo C# a seguir pressupõe esse esquema em uma tabela Oracle:The following C# example assumes this schema in an Oracle table:
(col1 number, col2 BFILE)
O exemplo demonstra como usar SetFileName os Read Seek métodos e para acessar um OracleBFile objeto.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);
}
}
}