Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > 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
Thread Tools

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
Guest
Posts: n/a
 
      07-29-2008
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 With Quote
 
 
 
 
Michael Nemtsev [MVP]
Guest
Posts: n/a
 
      07-29-2008
Hello dr,

as I remember if u don't flush and reopen it again you can't seek it

---
WBR,
Michael Nemtsev [Microsoft MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


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


 
Reply With Quote
 
 
 
 
Anthony Jones
Guest
Posts: n/a
 
      07-29-2008
"Patrice" <http://www.chez.com/scribe/> wrote in message
news:(E-Mail Removed)...
> Well, don't you have thought you could just try ?
>
> My findongs are quite as expected that is :
> - reading works (this is a buffer, reading a buffer you have written to is
> not really a problem)
> - content is not flushed on disk when seeking the origin. You can always
> flush explictely if needed (but this is not needed to be able to read the
> buffer)
>



My findings are different. Opening a file for read/write with shared read
causes will cause any written data to be flushed when Seek is used.
However an exclusive lock may cause the underlying OS API to make different
choices.

My adviced to DR (who has liberally multiposted this Q) is:-

>>

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

Which I posted in the dotnet.general group.


--
Anthony Jones - MVP ASP/ASP.NET


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
Share-Point-2010 ,Share-Point -2010 Training , Share-point-2010Hyderabad , Share-point-2010 Institute Saraswati lakki ASP .Net 0 01-06-2012 06:39 AM
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 ASP .Net Building Controls 0 07-29-2008 01:37 AM
Could a struct with size 44 bytes point always points to a char array with size 2024 bytes? eagle_jyjh@citiz.net C++ 8 04-10-2006 03:05 PM
Could a struct with size 44 bytes point always points to a char array with size 2048 bytes? eagle_jyjh@citiz.net C Programming 5 04-09-2006 02:49 PM



Advertisments