OracleBFile OracleBFile OracleBFile OracleBFile Class

定義

表示 Managed OracleBFile 物件,該物件是專為使用 Oracle BFILE 資料型別而設計的物件。Represents a managed OracleBFile object designed to work with the Oracle BFILE data type. 這個類別無法被繼承。This class cannot be inherited.

public ref class OracleBFile sealed : System::IO::Stream, ICloneable, System::Data::SqlTypes::INullable
public sealed class OracleBFile : System.IO.Stream, ICloneable, System.Data.SqlTypes.INullable
type OracleBFile = class
    inherit Stream
    interface ICloneable
    interface INullable
    interface IDisposable
Public NotInheritable Class OracleBFile
Inherits Stream
Implements ICloneable, INullable
繼承
實作

備註

OracleBFILE資料類型是一種 OracleLOB資料類型,包含最大值 4 gb 之二進位資料的參考。The Oracle BFILE data type is an Oracle LOB data type that contains a reference to binary data with a maximum size of 4 gigabytes. OracleBFILE不同於其他 OracleLOB資料類型,因為其資料會儲存在伺服器上的實體檔案而不是作業系統中。An Oracle BFILE differs from other Oracle LOB data types in that its data is stored in a physical file in the operating system instead of on the server. 請注意,BFILE資料類型提供唯讀存取資料。Note that the BFILE data type provides read-only access to data. 因此,寫入導向的方法繼承自Stream類別不支援。Therefore, write-oriented methods inherited from the Stream class are not supported.

其他特性BFILE資料類型,使其有別LOB資料類型包括:Other characteristics of a BFILE data type that distinguish it from a LOB data type are that it:

  • 包含非結構化資料。Contains unstructured data.

  • 支援伺服器端區塊。Supports server-side chunking.

  • 使用參考複製語意。Uses reference copy semantics. 例如,如果您在執行複製作業BFILE,則僅BFILE複製 (也就是檔案的參考) 的定位器。For example, if you perform a copy operation on a BFILE, only the BFILE locator (which is a reference to the file) is copied. 而不會複製檔案中的資料。The data in the file is not copied.

BFILE資料類型應該用於參考LOB的太大,因此不實際儲存在資料庫中。The BFILE data type should be used for referencing LOBs that are large in size, and therefore, not practical to store in the database. 會使用用戶端、 伺服器及通訊額外負荷BFILE資料類型相較於LOB資料型別。There is client, server, and communication overhead for using a BFILE data type compared to the LOB data type. 若要存取更有效率BFILE如果您只需要取得少量的資料。It is more efficient to access a BFILE if you only need to obtain a small amount of data. 它是更有效率的方式存取資料庫內建LOBs,如果您需要取得整個物件。It is more efficient to access database-resident LOBs if you need to obtain the entire object.

每個非 NULLOracleBFile物件會定義基礎實體檔案的位置的兩個實體與關聯:Each non-NULL OracleBFile object is associated with two entities that define the location of the underlying physical file:

  • Oracle DIRECTORY 物件 (檔案系統中目錄的資料庫別名) 及An Oracle DIRECTORY object, which is a database alias for a directory in the file system, and

  • 基礎實體檔案的檔名 (位於與 DIRECTORY 物件相關聯的目錄中)。The file name of the underlying physical file, which is located in the directory associated with the DIRECTORY object.

在後BFILE會建立,您可以擷取的形式在其定位器OracleBFile物件使用ExecuteReaderExecuteScalar方法。After a BFILE is created, you can retrieve its locator in the form of an OracleBFile object using the ExecuteReader or ExecuteScalar methods.

若要取得OracleBFile物件,請呼叫GetOracleBFile方法。To obtain an OracleBFile object, call the GetOracleBFile method.

實體檔案,OracleBFile的物件具有不需要存在,直到您嘗試存取它。The physical file that an OracleBFile object is associated with does not need to exist until you attempt to access it. 應用程式可以繫結OracleBFile不存在的檔案,請在預期的位置,建立實體檔案,然後呼叫ReadAn application can bind an OracleBFile to a nonexistent file, create the physical file in the expected location, and then call Read.

任何嘗試存取已關閉OracleBFile使用Read或是Seek方法再次開啟OracleBFile自動串流。Any attempt to access a closed OracleBFile using the Read or Seek methods reopens an OracleBFile stream automatically.

下列 C# 範例示範如何建立BFILE在 Oracle 資料表,然後再擷取它的形式OracleBFile物件。The following C# example demonstrates how you can create a BFILE in an Oracle table, and then retrieve it in the form of an OracleBFile object. 此範例示範如何使用OracleDataReader物件和OracleBFileSeekRead方法。The example demonstrates the use of the OracleDataReader object and the OracleBFileSeek and Read methods.

private void GetOracleBFile(string connectionString)
{
	//Create and open the connection.
	using (OracleConnection connection = new OracleConnection(connectionString))
	{
		connection.Open();

		//Create and execute the commands.
		OracleCommand command = connection.CreateCommand();
		command.CommandText = "CREATE OR REPLACE DIRECTORY TestDir AS 'c:\\bfiles'";
		command.ExecuteNonQuery();
		command.CommandText = "CREATE TABLE TestTable(col1 number, col2 BFILE)";
		command.ExecuteNonQuery();
		command.CommandText = "INSERT INTO TestTable VALUES ('2', BFILENAME('TESTDIR', 'File.jpg'))";
		command.ExecuteNonQuery();
		command.CommandText = "SELECT * FROM TestTable";

		//Read the BFile data.
		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);
				}
			}
		}
	}
	return;
}

如需有關建立和使用 Oracle BFILE,請參閱 Oracle 文件中的適當主題。For more information about creating and using an Oracle BFILE, see the appropriate topic in your Oracle documentation.

注意

BeginWriteEndWrite,並WriteByte方法,繼承自System.IO.Stream類別中,不支援,因為BFILE資料類型是唯讀的。The BeginWrite, EndWrite, and WriteByte methods, which are inherited from the System.IO.Stream class, are not supported because the BFILE data type is read-only.

欄位

Null Null Null Null

表示沒有繫結到實體檔案的 null OracleBFile 物件。Represents a null OracleBFile object that is not bound to a physical file.

屬性

CanRead CanRead CanRead CanRead

取得值,表示 BFILE 資料流是否可讀取。Gets a value indicating whether the BFILE stream can be read.

CanSeek CanSeek CanSeek CanSeek

取得值,表示是否可以執行向前及向後搜尋的作業。Gets a value indicating whether forward-seek and backward-seek operations can be performed.

CanTimeout CanTimeout CanTimeout CanTimeout

取得值,該值判斷目前的資料流是否可以逾時。Gets a value that determines whether the current stream can time out.

(Inherited from Stream)
CanWrite CanWrite CanWrite CanWrite

取得值,表示物件是否支援寫入。Gets a value indicating whether the object supports writing.

Connection Connection Connection Connection

取得 OracleConnection 的這個執行個體所使用的 OracleBFileGets the OracleConnection used by this instance of the OracleBFile.

DirectoryName DirectoryName DirectoryName DirectoryName

取得 DIRECTORY 物件的名稱,該物件與 OracleBFile 物件關聯。Gets the name of the DIRECTORY object, with which an OracleBFile object is associated.

FileExists FileExists FileExists FileExists

取得值,表示作業系統中是否有包含 BFILE 資料的實體檔案存在。Gets a value indicating whether a physical file containing BFILE data exists in the operating system.

FileName FileName FileName FileName

取得不含路徑的 BFILE 名稱。Gets the name of the BFILE without the path.

IsNull IsNull IsNull IsNull

取得值,指出 OracleBFile 是否為 Null 資料流。Gets a value that indicates whether the OracleBFile is a Null stream.

Length Length Length Length

取得值,傳回 OracleBFile 物件相關聯之實體檔案的長度 (以位元組為單位)。Gets a value that returns the length in bytes of the physical file with which the OracleBFile object is associated.

Position Position Position Position

取得 OracleBFile 資料流中目前的讀取位置。Gets the current read position in the OracleBFile stream.

ReadTimeout ReadTimeout ReadTimeout ReadTimeout

取得或設定值 (以毫秒為單位),這個值決定在逾時前資料流將嘗試讀取多長時間。Gets or sets a value, in milliseconds, that determines how long the stream will attempt to read before timing out.

(Inherited from Stream)
Value Value Value Value

取得 Array 型別的 Byte,其中含有 OracleBFile 資料。Gets an Array of type Byte that contains the OracleBFile data.

WriteTimeout WriteTimeout WriteTimeout WriteTimeout

取得或設定值 (以毫秒為單位),這個值決定在逾時前資料流將嘗試寫入多長時間。Gets or sets a value, in milliseconds, that determines how long the stream will attempt to write before timing out.

(Inherited from Stream)

方法

BeginRead(Byte[], Int32, Int32, AsyncCallback, Object) BeginRead(Byte[], Int32, Int32, AsyncCallback, Object) BeginRead(Byte[], Int32, Int32, AsyncCallback, Object) BeginRead(Byte[], Int32, Int32, AsyncCallback, Object)

開始非同步的讀取作業。Begins an asynchronous read operation. (請考慮用 ReadAsync(Byte[], Int32, Int32) 替代。)(Consider using ReadAsync(Byte[], Int32, Int32) instead.)

(Inherited from Stream)
BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object)

開始非同步的寫入作業。Begins an asynchronous write operation. (請考慮用 WriteAsync(Byte[], Int32, Int32) 替代。)(Consider using WriteAsync(Byte[], Int32, Int32) instead.)

(Inherited from Stream)
Clone() Clone() Clone() Clone()

會建立這個 OracleBFile 物件的複本,這個複本與原始物件一樣都會關聯到相同的實體檔案。Creates a copy of this OracleBFile object associated with the same physical file as the original.

Close() Close() Close() Close()

關閉目前資料流和釋放與目前資料流相關聯的任何資源 (例如通訊端和檔案控制代碼)。Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. 請確定正確地處置資料流,而非呼叫這個方法。Instead of calling this method, ensure that the stream is properly disposed.

(Inherited from Stream)
CopyTo(Int64, OracleLob, Int64, Int64) CopyTo(Int64, OracleLob, Int64, Int64) CopyTo(Int64, OracleLob, Int64, Int64) CopyTo(Int64, OracleLob, Int64, Int64)

以指定的資料量、來源位移和目的位移,從這個 OracleBFile 複製到目的 OracleLobCopies from this OracleBFile to a destination OracleLob with the specified amount of data, the source offset, and the destination offset.

CopyTo(OracleLob) CopyTo(OracleLob) CopyTo(OracleLob) CopyTo(OracleLob)

將這個 OracleBFile 的完整內容複製到目的 OracleLob 的開頭。Copies the entire contents of this OracleBFile to the beginning of a destination OracleLob.

CopyTo(OracleLob, Int64) CopyTo(OracleLob, Int64) CopyTo(OracleLob, Int64) CopyTo(OracleLob, Int64)

將這個 OracleBFile 的完整內容複製到指定位移 (Offset) 的目的 OracleLobCopies the entire contents of this OracleBFile to a destination OracleLob at the specified offset.

CopyTo(Stream) CopyTo(Stream) CopyTo(Stream) CopyTo(Stream)

從目前資料流讀取位元組,並將其寫入另一個資料流中。Reads the bytes from the current stream and writes them to another stream.

(Inherited from Stream)
CopyTo(Stream, Int32) CopyTo(Stream, Int32) CopyTo(Stream, Int32) CopyTo(Stream, Int32)

使用指定的緩衝區大小,從目前資料流讀取所有位元組,並將其寫入另一個資料流中。Reads the bytes from the current stream and writes them to another stream, using a specified buffer size.

(Inherited from Stream)
CopyToAsync(Stream) CopyToAsync(Stream) CopyToAsync(Stream) CopyToAsync(Stream)

以非同步的方式從目前資料流讀取所有位元組,並將其寫入另一個資料流中。Asynchronously reads the bytes from the current stream and writes them to another stream.

(Inherited from Stream)
CopyToAsync(Stream, CancellationToken) CopyToAsync(Stream, CancellationToken) CopyToAsync(Stream, CancellationToken) CopyToAsync(Stream, CancellationToken)

使用指定的取消權杖,以非同步的方式從目前資料流讀取位元組,並將其寫入另一個資料流。Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified cancellation token.

(Inherited from Stream)
CopyToAsync(Stream, Int32) CopyToAsync(Stream, Int32) CopyToAsync(Stream, Int32) CopyToAsync(Stream, Int32)

使用指定的緩衝區大小,以非同步的方式從目前資料流讀取所有位元組,並將其寫入另一個資料流中。Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified buffer size.

(Inherited from Stream)
CopyToAsync(Stream, Int32, CancellationToken) CopyToAsync(Stream, Int32, CancellationToken) CopyToAsync(Stream, Int32, CancellationToken) CopyToAsync(Stream, Int32, CancellationToken)

使用指定的緩衝區大小和取消語彙基元,以非同步的方式從目前資料流讀取位元組,並將其寫入另一個資料流。Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified buffer size and cancellation token.

(Inherited from Stream)
CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
CreateWaitHandle() CreateWaitHandle() CreateWaitHandle() CreateWaitHandle()

配置 WaitHandle 物件。Allocates a WaitHandle object.

(Inherited from Stream)
Dispose() Dispose() Dispose() Dispose()

釋放此物件所使用的全部資源。Releases all the resources that are used by this object.

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

釋放 Stream 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。Releases the unmanaged resources used by the Stream and optionally releases the managed resources.

(Inherited from Stream)
DisposeAsync() DisposeAsync() DisposeAsync() DisposeAsync()

以非同步方式釋放 Stream 使用的不受控資源。Asynchronously releases the unmanaged resources used by the Stream.

(Inherited from Stream)
EndRead(IAsyncResult) EndRead(IAsyncResult) EndRead(IAsyncResult) EndRead(IAsyncResult)

等候暫止的非同步讀取完成。Waits for the pending asynchronous read to complete. (請考慮用 ReadAsync(Byte[], Int32, Int32) 替代。)(Consider using ReadAsync(Byte[], Int32, Int32) instead.)

(Inherited from Stream)
EndWrite(IAsyncResult) EndWrite(IAsyncResult) EndWrite(IAsyncResult) EndWrite(IAsyncResult)

結束非同步的寫入作業。Ends an asynchronous write operation. (請考慮用 WriteAsync(Byte[], Int32, Int32) 替代。)(Consider using WriteAsync(Byte[], Int32, Int32) instead.)

(Inherited from Stream)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
Flush() Flush() Flush() Flush()

目前不支援。Not currently supported.

FlushAsync() FlushAsync() FlushAsync() FlushAsync()

以非同步的方式清除這個資料流的所有緩衝區,並造成所有緩衝資料都寫入基礎裝置。Asynchronously clears all buffers for this stream and causes any buffered data to be written to the underlying device.

(Inherited from Stream)
FlushAsync(CancellationToken) FlushAsync(CancellationToken) FlushAsync(CancellationToken) FlushAsync(CancellationToken)

以非同步的方式清除這個資料流的所有緩衝區,造成所有緩衝資料都寫入基礎裝置,並且監視取消要求。Asynchronously clears all buffers for this stream, causes any buffered data to be written to the underlying device, and monitors cancellation requests.

(Inherited from Stream)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

取得存留期服務物件,以控制這個執行個體的存留期原則。Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
ObjectInvariant() ObjectInvariant() ObjectInvariant() ObjectInvariant()

提供 Contract 的支援。Provides support for a Contract.

(Inherited from Stream)
Read(Byte[], Int32, Int32) Read(Byte[], Int32, Int32) Read(Byte[], Int32, Int32) Read(Byte[], Int32, Int32)

自目前 OracleBFile 讀取一位元組序列,並依所讀取的位元組數目進階資料流裡的位置。Reads a sequence of bytes from the current OracleBFile stream and advances the position within the stream by the number of bytes read.

Read(Span<Byte>) Read(Span<Byte>) Read(Span<Byte>) Read(Span<Byte>)

當在衍生類別中覆寫時,自目前資料流讀取一連串的位元組,並依所讀取的位元組數目進階資料流中的位置。When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

(Inherited from Stream)
ReadAsync(Byte[], Int32, Int32) ReadAsync(Byte[], Int32, Int32) ReadAsync(Byte[], Int32, Int32) ReadAsync(Byte[], Int32, Int32)

以非同步的方式從目前的資料流讀取位元組序列,並依讀取的位元組數將資料流中的位置往前移。Asynchronously reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

(Inherited from Stream)
ReadAsync(Byte[], Int32, Int32, CancellationToken) ReadAsync(Byte[], Int32, Int32, CancellationToken) ReadAsync(Byte[], Int32, Int32, CancellationToken) ReadAsync(Byte[], Int32, Int32, CancellationToken)

以非同步的方式從目前資料流讀取一連串的位元組、依所讀取的位元組數目進階資料流中的位置,以及監視取消要求。Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests.

(Inherited from Stream)
ReadAsync(Memory<Byte>, CancellationToken) ReadAsync(Memory<Byte>, CancellationToken) ReadAsync(Memory<Byte>, CancellationToken) ReadAsync(Memory<Byte>, CancellationToken)

以非同步的方式從目前資料流讀取一連串的位元組、依所讀取的位元組數目進階資料流中的位置,以及監視取消要求。Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests.

(Inherited from Stream)
ReadByte() ReadByte() ReadByte() ReadByte()

從資料流讀取一個位元組,並將資料流的位置推進一個位元組;如果在資料流末端,則傳回 -1。Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.

(Inherited from Stream)
Seek(Int64, SeekOrigin) Seek(Int64, SeekOrigin) Seek(Int64, SeekOrigin) Seek(Int64, SeekOrigin)

設定目前 OracleBFile 資料流上的位置。Sets the position on the current OracleBFile stream.

SetFileName(String, String) SetFileName(String, String) SetFileName(String, String) SetFileName(String, String)

OracleBFile 物件繫結到作業系統中不同的檔案。Binds the OracleBFile object to a different file in the operating system.

SetLength(Int64) SetLength(Int64) SetLength(Int64) SetLength(Int64)

目前不支援。Not currently supported.

ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)
Write(Byte[], Int32, Int32) Write(Byte[], Int32, Int32) Write(Byte[], Int32, Int32) Write(Byte[], Int32, Int32)

目前不支援。Not currently supported.

Write(ReadOnlySpan<Byte>) Write(ReadOnlySpan<Byte>) Write(ReadOnlySpan<Byte>) Write(ReadOnlySpan<Byte>)

在衍生類別中覆寫時,將一連串的位元組寫入目前的資料流,並且由這個資料流中目前的位置前移寫入的位元組數目。When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

(Inherited from Stream)
WriteAsync(Byte[], Int32, Int32) WriteAsync(Byte[], Int32, Int32) WriteAsync(Byte[], Int32, Int32) WriteAsync(Byte[], Int32, Int32)

以非同步的方式將位元組序列寫入至目前的資料流,並依寫入的位元組數將資料流中目前的位置往前移。Asynchronously writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

(Inherited from Stream)
WriteAsync(Byte[], Int32, Int32, CancellationToken) WriteAsync(Byte[], Int32, Int32, CancellationToken) WriteAsync(Byte[], Int32, Int32, CancellationToken) WriteAsync(Byte[], Int32, Int32, CancellationToken)

以非同步的方式將一連串的位元組寫入目前的資料流,由這個資料流中目前的位置前移寫入的位元組數目,並且監視取消要求。Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.

(Inherited from Stream)
WriteAsync(ReadOnlyMemory<Byte>, CancellationToken) WriteAsync(ReadOnlyMemory<Byte>, CancellationToken) WriteAsync(ReadOnlyMemory<Byte>, CancellationToken) WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)

以非同步的方式將一連串的位元組寫入目前的資料流,由這個資料流中目前的位置前移寫入的位元組數目,並且監視取消要求。Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.

(Inherited from Stream)
WriteByte(Byte) WriteByte(Byte) WriteByte(Byte) WriteByte(Byte)

寫入一個位元組至資料流的目前位置,並將資料流位置推進一個位元組。Writes a byte to the current position in the stream and advances the position within the stream by one byte.

(Inherited from Stream)

明確介面實作

IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose()

釋放 Stream 所使用的所有資源。Releases all resources used by the Stream.

(Inherited from Stream)

適用於