IsolatedStorageFileStream.BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) 方法

定义

开始异步写。Begins an asynchronous write.

public:
 override IAsyncResult ^ BeginWrite(cli::array <System::Byte> ^ buffer, int offset, int numBytes, AsyncCallback ^ userCallback, System::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
Public Overrides Function BeginWrite (buffer As Byte(), offset As Integer, numBytes As Integer, userCallback As AsyncCallback, stateObject As Object) As IAsyncResult

参数

buffer
Byte[]

数据写入的缓冲区。The buffer to write data to.

offset
Int32

buffer 中的字节偏移量,从此处开始写入。The byte offset in buffer at which to begin writing.

numBytes
Int32

要写入的最大字节数。The maximum number of bytes to write.

userCallback
AsyncCallback

异步写操作完成后调用的方法。The method to call when the asynchronous write operation is completed. 此参数是可选的。This parameter is optional.

stateObject
Object

异步写的状态。The status of the asynchronous write.

返回

表示可能仍处于挂起状态的异步写入的 IAsyncResultAn IAsyncResult that represents the asynchronous write, which is possibly still pending. IAsyncResult 必须传递到该流的 EndWrite(IAsyncResult) 方法以确保写入完成,然后相应地释放资源。This IAsyncResult must be passed to this stream's EndWrite(IAsyncResult) method to ensure that the write is complete, then frees resources appropriately. 这可以通过调用 BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) 的相同代码来完成,或在传递给 BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) 的回调中完成。This can be done either by the same code that called BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) or in a callback passed to BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object).

异常

试图超出文件末尾进行异步写入。An asynchronous write was attempted past the end of the file.

注解

如果 IsolatedStorageFileStream 对象是可写的,则在流的末尾写入会扩展流。If a IsolatedStorageFileStream object is writable, writing at the end of the stream expands the stream.

发出异步读取或写入操作时,将更新流中的当前位置,而不是在 i/o 操作完成时进行更新。The current position in the stream is updated when you issue the asynchronous read or write, not when the I/O operation completes.

必须通过此方法返回的 IAsyncResult 对象调用 EndWrite,以找出写入的字节数。You must call EndWrite with the IAsyncResult object that this method returns to find out how many bytes were written.

适用于