windows - error to write text to a text file line by line by appending in C# , but got nothing in the file -


this question has answer here:

i working on c# on win7 vs 2012.

i need write text text file line line appending.

 streamwriter ofile = new streamwriter(@"c:\mypath\my_data_output.txt", true);    ofile.writeline(mystring + "\t"); 

but, there nothing in output file.

any appreciated.

enclose code in using clause. call dispose method on streamwriter class. dispose method calls flush method, writes stream.

your code this:

using (streamwriter ofile =             new streamwriter(@"c:\mypath\my_data_output.txt", true) {     ofile.writeline(mystring + "\t");  } 

you can call flush method @ time.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -