System.IO.StreamWriter Close or Flush method to shut down the computer in such a way that just part

D

Daniel

System.IO.StreamWriter Close or Flush method to shut down the computer in
such a way that just part of the file is written? or an empty file is
written? Also if the Close or Flush is to a streamwriter writing to a
network share, is it possible for the network to go down in such a way that
the tartet file is only partialy written? or are there some kind of check
sums to prevent this.
 
H

Helge Jensen

Daniel said:
System.IO.StreamWriter Close or Flush method to shut down the computer in
such a way that just part of the file is written? or an empty file is
written? Also if the Close or Flush is to a streamwriter writing to a
network share, is it possible for the network to go down in such a way that
the tartet file is only partialy written? or are there some kind of check
sums to prevent this.

I'm not really sure what you are asking here. I am going to guess that
you are asking:

Can I be sure that all data written to StreamWriter is written to the
underlying Stream?

If Flush or Close completes without exceptions, all data should be sent
to the underlying stream. Any guarantee beyound that are given by the
stream.

(The following statements assume you are using synchronueous Streams and
operations on them)

If you are writing to a FileStream, the underlying file should be fully
written, not partially, but there is no assurance from FileStream, that
the computer cannot be reset or whatever and the file is left only
partially updated on disk. Such a guarantee comes from the file-system
itself.

If you are writing to a TCP-based NetworkStream, then you will know that
the receiving side acknowledged your entire stream content, but it may
*not* update it's state, since it may be reset before processing the
package.

If you are writing to an UDP-based NetworkStream, you will not know
anything but that all packages have left your process and these may, or
may not reach their destination.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top