Hi. I am learning ASP.net programming language. I want to know that how to read text file in asp.net. I tried different code but none of them worked out. If you have any in solution please let me know that. Thanks in advanced.
Hi. I am learning ASP.net programming language. I want to know that how to read text file in asp.net. I tried different code but none of them worked out. If you have any in solution please let me know that. Thanks in advanced.
The given code will help us to read the file content and using StringBuilder object. Add System.IO namespace for this code to work.
Code:string root = Server.MapPath("~"); string Template = root +"\test.txt"; StringBuilder line = new StringBuilder(); using (StreamReader rwOpenTemplate = new StreamReader(Template)) { while (!rwOpenTemplate.EndOfStream) { line.Append(rwOpenTemplate.ReadToEnd()); } }
Bookmarks