471,321 Members | 1,704 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

flush works , but there is a time issue.

(a little more info)
after flushing the line (instead of closing streamwirter)
it takes some x time to flush the line
so, when I read from the file I cannot find the last written line.

if I close the streamwriter it does find the line always.
but , my next write fails "Cannot write to a closed TextWriter"

Aug 6 '08 #1
5 1835
raulavi wrote:
(a little more info)
after flushing the line (instead of closing streamwirter)
it takes some x time to flush the line
so, when I read from the file I cannot find the last written line.

if I close the streamwriter it does find the line always.
but , my next write fails "Cannot write to a closed TextWriter"
Flushing the StreamWriter doesn't flush the underlying FileStream. You
have to flush that after flushing the StreamWriter for the line to end
up in the file.

--
Göran Andersson
_____
http://www.guffa.com
Aug 6 '08 #2
Thanks Goran...
Sorry, could you explain a lit bit .

so how is this process done?

write a line
?????close, flush or what???

????what do we need here to
read the last line written

"Göran Andersson" wrote:
raulavi wrote:
(a little more info)
after flushing the line (instead of closing streamwirter)
it takes some x time to flush the line
so, when I read from the file I cannot find the last written line.

if I close the streamwriter it does find the line always.
but , my next write fails "Cannot write to a closed TextWriter"

Flushing the StreamWriter doesn't flush the underlying FileStream. You
have to flush that after flushing the StreamWriter for the line to end
up in the file.

--
Göran Andersson
_____
http://www.guffa.com
Aug 7 '08 #3
On Thu, 07 Aug 2008 08:53:01 -0700, raulavi
<ra*****@discussions.microsoft.comwrote:
Thanks Goran...
Sorry, could you explain a lit bit .

so how is this process done?
StreamWriter writer = ...;

writer.Flush();
writer.BaseStream.Flush();

Pete
Aug 7 '08 #4
Thanks Peter and Goran,

I will test it.

"Peter Duniho" wrote:
On Thu, 07 Aug 2008 08:53:01 -0700, raulavi
<ra*****@discussions.microsoft.comwrote:
Thanks Goran...
Sorry, could you explain a lit bit .

so how is this process done?

StreamWriter writer = ...;

writer.Flush();
writer.BaseStream.Flush();

Pete
Aug 7 '08 #5
writer.BaseStream.Flush();

is the solution... at least for my prototype. Lets see the real thing..

thanks againg to all.

"Peter Duniho" wrote:
On Thu, 07 Aug 2008 08:53:01 -0700, raulavi
<ra*****@discussions.microsoft.comwrote:
Thanks Goran...
Sorry, could you explain a lit bit .

so how is this process done?

StreamWriter writer = ...;

writer.Flush();
writer.BaseStream.Flush();

Pete
Aug 7 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Jon Spivey | last post: by
30 posts views Thread by Jonathan Neill | last post: by
reply views Thread by Matthias Straka | last post: by
1 post views Thread by nitroamos | last post: by
12 posts views Thread by Daniel Kaplan | last post: by
2 posts views Thread by Kiran | last post: by
1 post views Thread by asleepatdesk | last post: by
2 posts views Thread by Damir | last post: by
reply views Thread by rosydwin | 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.