ASP.NET (35) SQL (25) JAVASCRIPT (24) HTML (14) STYLE SHEET (6) ASP (4) SCRIPT (1)

Search me out HERE!!

White text in simple text file using ASP.Net with C#

Use below code to write text in simple .txt file using ASP.Net with C#:

System.IO.StreamWriter sw = new System.IO.StreamWriter(Server.MapPath("C:\\test.txt"));
sw.WriteLine("Kapil Baheti");
sw.Close();

Above code will write "Kapil Baheti" in test.txt file. Also if file is not present at destination then it will be created automatically. 

No comments:

Post a Comment