user14647438
user14647438

Reputation:

System.IO.DirectoryNotFoundException could not find a part of the route

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.

Upvotes: 0

Views: 422

Answers (1)

labilbe
labilbe

Reputation: 3584

string route = Server.MapPath(@"~\\file\\myfile.txt");
string[] line = System.IO.File.ReadAllLines(route);

Upvotes: 1

Related Questions