Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - When using System.IO.FileStream, I write 8 bytes, then seek to the start of the file, does the 8 bytes get flushed on seek and the buffer become a readbuffer at that point instead of being a write buffer?

Reply
 
Old 07-28-2008   #1 (permalink)
DR


 
 

When using System.IO.FileStream, I write 8 bytes, then seek to the start of the file, does the 8 bytes get flushed on seek and the buffer become a readbuffer at that point instead of being a write buffer?

When using System.IO.FileStream, I write 8 bytes, then seek to the start of
the file, does the 8 bytes get flushed on seek and the buffer become a
readbuffer at that point instead of being a write buffer?



My System SpecsSystem Spec
Old 07-29-2008   #2 (permalink)
Anthony Jones


 
 

Re: When using System.IO.FileStream, I write 8 bytes, then seek to the start of the file, does the 8 bytes get flushed on seek and the buffer become a readbuffer at that point instead of being a write buffer?


"DR" <softwareengineer98037@xxxxxx> wrote in message
news:OZoyDzR8IHA.1200@xxxxxx
Quote:

> When using System.IO.FileStream, I write 8 bytes, then seek to the start
of
Quote:

> the file, does the 8 bytes get flushed on seek and the buffer become a
> readbuffer at that point instead of being a write buffer?
>
>
A simple experiment in .NET 2.0 and Windows XP shows that it does appear to
flush on the seek.

However whether you should rely in that behaviour depends on why you asked
the question. If you are worried that you might be overwritting data that
hasn't been stored yet then don't be.

If you want to make sure that data is persisted before doing other things
then you should explicitly flush. Just because seek appears to flush in a
the above case may simply be a result of specific OS decisions. In other
circumstances the underlying OS (on windows FileStream is a fairly
transparent wrapper on the Win APIs for these operations) may make other
choices.

--
Anthony Jones - MVP ASP/ASP.NET


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
how to get powershell to write to event log or write a log file? PowerShell
Hide N' Go Seek HDD Vista hardware & devices
Please advise where to seek help? Vista General
Slow File transfer - 0 bytes/sec General Discussion
Windows Explorer: Display File Size Column In Bytes? Vista file management


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46