By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,925 Members | 732 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,925 IT Pros & Developers. It's quick & easy.

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 th

P: n/a
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.
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Daniel wrote:
System.IO.StreamWriter Close or Flush method to shut down the computer in
such a way that just part of the file is written?
I don't know if I understood this...

Do you want to make sure that your file is being written to disk, even
if the computer is shut down before you called Close?
Use Flush - it will write everything in the internal buffer to disk.
You can try it yourself without shutting down the computer - just don't
use Flush but immediately exit the Application after you called Write a
few times - the file will most certainly be incomplete...

or an empty file is
written?


That depends on how often you use Flush. If you use it after each byte
you write, all will be on the disk but this has a very bad performance.
Best thing may be to use Flush manually after each important block of
data you wrote and before Close.

--
Pascal Schmitt
Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Browse more .NET Framework Questions on Bytes