IsolatedStorageFileStream.BeginWrite 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
開始異步寫入。
public:
override IAsyncResult ^ BeginWrite(cli::array <System::Byte> ^ array, int offset, int numBytes, AsyncCallback ^ userCallback, System::Object ^ stateObject);
public:
override IAsyncResult ^ BeginWrite(cli::array <System::Byte> ^ buffer, int offset, int numBytes, AsyncCallback ^ userCallback, System::Object ^ stateObject);
public override IAsyncResult BeginWrite(byte[] array, int offset, int numBytes, AsyncCallback? userCallback, object? stateObject);
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int numBytes, AsyncCallback userCallback, object stateObject);
override this.BeginWrite : byte[] * int * int * AsyncCallback * obj -> IAsyncResult
override this.BeginWrite : byte[] * int * int * AsyncCallback * obj -> IAsyncResult
Public Overrides Function BeginWrite (array As Byte(), offset As Integer, numBytes As Integer, userCallback As AsyncCallback, stateObject As Object) As IAsyncResult
Public Overrides Function BeginWrite (buffer As Byte(), offset As Integer, numBytes As Integer, userCallback As AsyncCallback, stateObject As Object) As IAsyncResult
參數
- bufferarray
- Byte[]
用來寫入資料的緩衝區。
- offset
- Int32
開始寫入的位元組偏移 buffer 。
- numBytes
- Int32
最大可寫入位元組數。
- userCallback
- AsyncCallback
非同步寫入操作完成後呼叫的方法。 這是選擇性參數。
- stateObject
- Object
非同步寫入的狀態。
傳回
代表 IAsyncResult 非同步寫入,可能還在等待中。 必須將此 IAsyncResult 資料傳遞給該串流的方法 EndWrite(IAsyncResult) ,以確保寫入完成,然後適當釋放資源。 這可以透過呼叫的 BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) 程式碼完成,或是回調傳給 BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object)。
例外狀況
檔案結束後嘗試非同步寫入。
備註
如果物件 IsolatedStorageFileStream 是可寫的,在串流末端寫入會擴展串流。
串流中當前位置會在你發出非同步讀寫時更新,而非 I/O 操作完成時更新。
你必須用EndWrite這個方法回傳的物件來IAsyncResult呼叫,才能知道寫入了多少位元組。