C# FileStream Write
Description
FileStream Write
Writes a block of bytes to the file stream.
Syntax
FileStream.Write
has the following syntax.
public override void Write(
byte[] array,/* www . j av a 2 s .c o m*/
int offset,
int count
)
Parameters
FileStream.Write
has the following parameters.
array
- The buffer containing data to write to the stream.offset
- The zero-based byte offset in array from which to begin copying bytes to the stream.count
- The maximum number of bytes to write.
Returns
FileStream.Write
method returns
Example
//from w w w. j av a 2s .c o m
using System;
using System.IO;
class TestRW
{
public static void Main(String[] args)
{
FileStream fs = new FileStream("MyFile.txt", FileMode.OpenOrCreate, FileAccess.Read);
fs.Write(new byte[]{1,2,3,4,5,6},0,3);
}
}