Reputation: 1548
There is an existing process that is writing to a text file on my site. Let's say the file is at http://www.mysite.com/addresses/addresses.txt
I have been able to successfully display the contents of the file in a text box using client.DownloadString, however I can't find a clear answer on how to append to the end of this text file and also to clear the contents of this file. This is a text file on my web server.
I'm working in C#. I do know the path to the file on the server at c:\inetpub\site\addresses\address.txt as well.
Any ideas on how to append or clear this file? Everything I seem to find on it is on windows forms and i don't use enough DotNet to know where to look.
Thanks!
Upvotes: 0
Views: 1709
Reputation: 223282
Check out this Article CodeSnip: Read and Write Text Files with ASP.NET 2.0
System.IO.StreamWriter StreamWriter1 =
new System.IO.StreamWriter(Server.MapPath("test.txt"));
StreamWriter1.WriteLine(TextBox1.Text);
StreamWriter1.Close();
Upvotes: 1