user2038443
user2038443

Reputation: 163

find out how many bytes have been written to a filestream

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

Answers (2)

DotNetUser
DotNetUser

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

SLaks
SLaks

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

Related Questions