Content feed Comments Feed

The Official ASATO Site

Hi, welcome to my blog. ASP,asp.net,Health,Javascript,JQUERY

How to read text file in asp.net

Posted by admin On April - 14 - 2010

this is show how to read text from a text file(C#).

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
string str = "";
using (StreamReader sr = new StreamReader("G:\\zencart\\categorytlinks.txt", System.Text.Encoding.Default)) {
     strline = sr.ReadLine();
     while(strline!=null){
          str += strline+"\r\n";
     }
     sr.Dispose();
     sr.Close();
}
Response.Write(str);

Comments are closed.