Friday, October 11, 2013

Write Line in Text File

Today I also just quickly publish the code to write a line to a text file. In a previous post I already explained the principle. The following code writes the line "Factorial" to the file "newposts.txt" on my desktop, the parameter true in the constructor of the StreamWriter says, that the line is to be appended to the file - if it is false, the file is overwritten:

System.IO.StreamWriter sw = new System.IO.StreamWriter(@"C:\Users\Oliver\Desktop\newposts.txt", true);

No comments:

Post a Comment