Reputation: 73
I am having an issue trying to reference a drive\path on another on the same network as my application.
string LocationPath = "\\servername\F$\FirstDirectory\SecondDirectory\filename.txt";
I would like to use streamreader to capture the contents of this file but can't seem to access it. This is how I reference the directory in file explorer, how can it be done in C#?
Thanks for any input!
Upvotes: 2
Views: 5275
Reputation: 3073
You need to escape the backslash:
string LocationPath = "\\\\servername\\F$\\FirstDirectory\\SecondDirectory\\filename.txt";
Or use a verbatim string:
string LocationPath = @"\\servername\F$\FirstDirectory\SecondDirectory\filename.txt";
Upvotes: 2