Reputation: 163
I am using FileStream.Write()
method for a server\client program. I am trying to find out if all the bytes have been written to the FileStream
by using
" int byteswritten = FileStream.Write(bytes1,0,bytes1.length);
"
I have noticed the FileStream.Read() method supports this feature but the FileStream.Write() method does not. does this method always write the bytes? If not then why isn't this supported?
Upvotes: 1
Views: 1749
Reputation: 6612
It will always write entire bytes.
MSDN FileStream.Write: Writes a block of bytes to this stream using data from a buffer.
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.
Upvotes: 1
Reputation: 887365
Stream.Write()
is specified to always write the entire input, or throw an exception.
Therefore, there is no point in returning this value.
Upvotes: 2