Search
このインスタンス・メソッドでは、OracleBFile
の現行のインスタンスのバイナリ・パターンを検索します。
宣言
// C# public int Search(byte[] val, Int64 offset, Int64 nth);
パラメータ
-
val
検索対象のバイナリ・パターン
-
offset
OracleBFile
の検索が開始される0
ベース・オフセット(バイト) -
nth
オフセットが戻される特定の一致の状態(
1
ベース)
戻り値
一致のnth
回目の出現に対して、一致パターン(バイト表示)の起点の絶対offset
を戻します。それ以外の場合は、0
を戻します。
例外
ObjectDisposedException
- オブジェクトはすでに処理されています。
InvalidOperationException
- OracleConnection
がオープンされていないか、またはオブジェクトの存続中にクローズされています。
ArgumentOutOfRangeException
- offset
が0
未満の場合、nth
が0
以下の場合、val
.Length
が16383
より大きい場合、nth
がOracleBFile.MaxSize
以上の場合またはoffset
がOracleBFile.MaxSize
以上の場合のいずれか。
備考
検索パターンの制限は16383バイトです。
例
// 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 SearchSample { 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(); // 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(); } }