0

I wanted to read and parse a .txt file by calling it in the project's folder. this is the read code

string[] line = { };
string route = @"~\\file\\" + ".text";
line = System.IO.File.ReadAllLines(route);

the error comes when it tries to read all the lines from the file, it goes to another route that is the following:

C:\Program Files (x86)\IIS Express\~\Files\.text

and the project is located on the D drive.

Dale K
  • 16,372
  • 12
  • 37
  • 62
  • You need `Server.MapPath` https://stackoverflow.com/questions/275781/server-mappath-server-mappath-server-mappath-server-mappath – VDWWD Nov 16 '20 at 11:06

1 Answers1

1
string route = Server.MapPath(@"~\\file\\myfile.txt");
string[] line = System.IO.File.ReadAllLines(route);
labilbe
  • 3,218
  • 2
  • 24
  • 34