A
ad
I have a text file in the directory of my web application.
How can I read this text file into a string vaiable?
How can I read this text file into a string vaiable?
{
StreamReader sr = File.OpenText(filename);
StringBuilder sb = new StringBuilder();
string str = sr.ReadLine();
while( str != null )
{
sb.Append(str + "\n");
str = sr.ReadLine();
}
sr.Close();
return sb.ToString();
}
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.