日本語PDF

OracleBFileクラス

OracleBFileは、BFILEデータへの参照が含まれるオブジェクトです。このオブジェクトは、BFILEに対して操作を実行するためのメソッドを提供します。

注意:

OracleBFileは、Oracle8.x以降に対して実行されるアプリケーションでサポートされています。

クラスの継承

System.Object

  System.MarshalByRefObject

    System.IO.Stream

             Oracle.DataAccess.Types.OracleBFile

宣言

// C#
public sealed class OracleBFile : Stream, ICloneable, INullable

要件

プロバイダ ODP.NET管理対象外ドライバ ODP.NET管理対象ドライバ ODP.NET Core

アセンブリ

Oracle.DataAccess.dll

Oracle.ManagedDataAccess.dll

Oracle.ManagedDataAccess.dll

ネームスペース

Oracle.DataAccess.Client

Oracle.ManagedDataAccess.Client

Oracle.ManagedDataAccess.Client

.NET Framework

3.5, 4.5, 4.6, 4.7

4.5, 4.6, 4.7

4.6.1以降

.NET Core

-

-

2.1以降

スレッド安全性

パブリック静的メソッドはスレッドセーフですが、インスタンス・メソッドではスレッド安全性は保証されません。

備考

OracleBFileは、Oracle8.x以降に対して実行されるアプリケーションでサポートされています。

// Database Setup, if you have not done so yet.
/* Log on as DBA (SYS or SYSTEM) that has CREATE ANY DIRECTORY privilege.
 
CREATE OR REPLACE DIRECTORY MYDIR AS 'C:\TEMP';
 
*/
 
// C#
 
using System;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
 
class OracleBFileSample
{
static void Main()
{
    // Create MYDIR directory object as indicated previously and create a file
    // MyFile.txt with the text ABCDABC under C:\TEMP directory.
    // Note that the byte representation of the ABCDABC is 65666768656667
 
    string constr = "User Id=scott;Password=tiger;Data Source=oracle";
    OracleConnection con = new OracleConnection(constr);
    con.Open();
 
    OracleBFile bFile = new OracleBFile(con, "MYDIR", "MyFile.txt");
 
    // Open the OracleBFile
    bFile.OpenFile();
 
    // Read 7 bytes into readBuffer, starting at buffer offset 0
    byte[] readBuffer = new byte[7];       
    int bytesRead = bFile.Read(readBuffer, 0, 7);
    
    // Prints "bytesRead  = 7"
    Console.WriteLine("bytesRead  = " + bytesRead);    
 
    // Prints "readBuffer = 65666768656667"
    Console.Write("readBuffer = ");
    for(int index = 0; index <  readBuffer.Length; index++)
    {
      Console.Write(readBuffer[index]);
    }
    Console.WriteLine();
 
    // Search for the 2nd occurrence of a byte pattern {66,67}
    // starting from byte offset 1 in the OracleBFile
    byte[] pattern = new byte[2] {66, 67};
    long posFound = bFile.Search(pattern, 1, 2);
    
    // Prints "posFound   = 6" 
    Console.WriteLine("posFound   = " + posFound);
    
    // Close the OracleBFile
    bFile.CloseFile();
 
    bFile.Close();
    bFile.Dispose();
 
    con.Close();
    con.Dispose();
}
}