The following code tell your how to read file(s):
Add main namespace for this operation
using System.IO;
Read html file
string file = Server.MapPath ("abc.html");
StreamReader sr;
FileInfo fi = new FileInfo(file);
string input = "";
if( File.Exists(file) )
{
sr = File.OpenText(file);
input += Server.HtmlEncode( sr.ReadToEnd() );
sr.Close();
}
input += "";
Label1.Text = input;
Read text file
StreamReader sr = File.OpenText(Server.MapPath("abc.txt"));
string strContents = sr.ReadToEnd();
//To display normal raw contentsResponse.Write(strContents);
//To handle Carriage returnsResponse.Write(strContents.Replace("\n" , ""));
sr.Close();
Thanks and Regards
Varun Bansal
Assitant Programmer
NIC, Jaipur
No comments:
Post a Comment