472,127 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

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

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
1 3576
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.

Similar topics

9 posts views Thread by Penn Markham | last post: by
12 posts views Thread by benjamin.krulewitch | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.