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!
Talk1:
did you give access to folder/File for Network User/IIS Users
Talk2:
I am/visual studio/application is in the network, if I type \servername\F$\FirstDirectory\SecondDirectory\filename.txt with two backslashes to start in the file explorer it can find the file. But programmatically I am not able to do the same?
Solutions1
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";
Talk1:
The verbatim string you provided is exactly the string I used.
Talk2:
I had the proper solution, I must've had the directory wrong. Sorry guys. But the correct answer is this one for future reference