-
June 23rd, 2010, 01:22 PM
#1
StreamWriter go to end of file?
Hello, when I use streamwriter, it writes the data, then puts the cursor to the top of the document, it tends to overwrite it I think? How do I make it go at the bottom so it prints the next lot below it?
StreamWriter.EndOfStream(); doesn't work
-
June 23rd, 2010, 01:25 PM
#2
Re: StreamWriter go to end of file?
you are being very vague, and what you are saying is not true. You probably need to post some code, so that we can see where you are going wrong.
-
June 23rd, 2010, 01:30 PM
#3
Re: StreamWriter go to end of file?
Sorry, I am ignorant. I just started C# the other day.
Code:
static void Header1(_cnf cnf, string var1, string var2, string var3, StreamWriter logF)
{
logF.WriteLine("------------------------------------------");
logF.WriteLine("Text: "+ var1);
logF.WriteLine("Text: "+ var2);
logF.WriteLine("Text: "+ var3);
// Need to go to the end of the file.
logF.Flush();
}
Does that help at all?
- Tom
-
June 23rd, 2010, 01:33 PM
#4
Re: StreamWriter go to end of file?
Helps a little. Actually you should probably look at the overloaded methods for creating your stream writer. There is an overload with a boolean parameter for appending to the file instead of overwriting.
Code:
System.IO.StreamWriter aa = new System.IO.StreamWriter("myfile.txt", true);
-
June 23rd, 2010, 01:41 PM
#5
Re: StreamWriter go to end of file?
It still does not help me, or the previous poster. We need to see more code flow, if you are opening and closing the stream everytime you want to write, then you need to use the append flag. If you open the stream once and write everything, there is something else wrong.
-
June 23rd, 2010, 01:51 PM
#6
Re: StreamWriter go to end of file?
sotoasty's post solved it for me, thanks
thanks guys
-
November 14th, 2013, 10:40 AM
#7
Re: StreamWriter go to end of file?
@sotoasty ; Thank you very much bro, i didn't even know there is an overload with a Boolean , that [,true] parameter, made everything True, Thanks again.
-
November 15th, 2013, 05:15 PM
#8
Re: StreamWriter go to end of file?
Originally Posted by Zaki Al-Qudah
@sotoasty ; Thank you very much bro, i didn't even know there is an overload with a Boolean , that [,true] parameter, made everything True, Thanks again.
Glad this old post helped, but no need to guess what is available or rely on a 3 year old thread. Instead take a look at what is available for the class you are interested in in Msdn.
http://msdn.microsoft.com/en-us/libr...v=vs.110).aspx
The msdn documentation will show you the different constructors, properties and methods for a class. Often it will also show you sample code as well.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|