Accessing Password Protected Network Drives in Windows in C#?
Posted
by tkeE2036
on Stack Overflow
See other posts from Stack Overflow
or by tkeE2036
Published on 2010-04-01T21:09:42Z
Indexed on
2010/04/01
21:13 UTC
Read the original article
Hit count: 237
Hi Everyone,
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!!
© Stack Overflow or respective owner