So in C# I am trying to access a file on a network, for example at "//applications/myapp/test.txt", as follows:
const string fileLocation = @"//applications/myapp/test.txt";
using (StreamReader fin = new StreamReader(FileLocation))
{
while(!fin.EndOfStream()){
//Do some cool stuff with file
}
}
However I get the following error:
System.IO.IOException : Logon failure: unknown user name or bad password.
I figure its because I need to supply some network credentials but I'm not sure how to get those to work in this situation.
Does anyone know the best way (or any way) to gain access to these files that are on a a password protected location?
Thanks in advance!!
This question got me to where I needed to be pretty quickly in the same case.
Here's how I adapted the code:
followed by