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

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -