How can I read the contents of a text file in my web application using the relative path / URL?
The files are located in the root of my app in a directory.
I do not want to specify the full path of the file that I want to access because my test environment is not correct, the mirror of my production environment.
Use Server.MapPath ("/ path / to / file")
And pass the result of the file. ReadAllText ()
:
string template file =. All text (Server.MapPath ("~ / templates /") + file name);
No comments:
Post a Comment