FileStream.Write Method
Assembly: mscorlib (in mscorlib.dll)
public void Write ( byte[] array, int offset, int count )
public override function Write ( array : byte[], offset : int, count : int )
Not applicable.
Parameters
- array
The buffer containing data to write to the stream.
- offset
The zero-based byte offset in array at which to begin copying bytes to the current stream.
- count
The number of bytes to be written to the current stream.
| Exception type | Condition |
|---|---|
| array is a null reference (Nothing in Visual Basic). | |
| offset and count describe an invalid range in array. | |
| offset or count is negative. | |
| An I/O error occurs. - or - Another thread may have caused an unexpected change in the position of the operating system's file handle. | |
| The stream is closed. | |
| The current stream instance does not support writing. |
This method overrides Write.
The offset parameter gives the offset of the byte in array (the buffer index) at which to begin copying, and the count parameter gives the number of bytes that will be written to the stream. If the write operation is successful, the current position of the stream is advanced by the number of bytes written. If an exception occurs, the current position of the stream is unchanged.
Note: |
|---|
| Use the CanWrite property to determine whether the current instance supports writing. For additional information, see CanWrite. |
For a list of common I/O tasks, see Common I/O Tasks.
This code example is part of a larger example provided for the Lock method.
// Write the original file data. if(fileStream.Length == 0) { tempString = lastRecordText + recordNumber.ToString(); fileStream.Write(uniEncoding.GetBytes(tempString), 0, uniEncoding.GetByteCount(tempString)); }
// Write the original file data.
if ( fileStream.get_Length() == 0 ) {
tempString = lastRecordText +(
new Integer( recordNumber)).ToString();
fileStream.Write(uniEncoding.GetBytes(tempString),
0, uniEncoding.GetByteCount(tempString));
}
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.
Note: