Click here to Skip to main content
15,901,205 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I intend to show a text file from app_data folder.
I get error stating that path could not be found. How to code the correct path?


XML
string inputString;
resultLabel.Text = "";
using (StreamReader streamReader = File.OpenText(@"~\App_Data\New Text Document.txt"))
{
inputString = streamReader.ReadLine();
while (inputString != null)
{
resultLabel.Text += inputString + "<br />";
inputString = streamReader.ReadLine();
Posted

1 solution

Try:
C#
using (StreamReader streamReader = File.OpenText(Server.MapPath(@"~\App_Data\New Text Document.txt")))
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900