S
siddharth_jain_1
Hello
I am trying to get a list of shared files and subdirectories in a
particular folder on a server.
For this I am using DirectoryInfo in the following way.
DirectoryInfo folder = new
DirectoryInfo("\\\\server_name\\shared_folder_name");
FileInfo[] fiArr = folder.GetFiles();
DirectoryInfo[] diArr = folder.GetDirectories();
foreach (FileInfo fri in fiArr)
Console.WriteLine(fri.Name);
foreach (DirectoryInfo di in diArr)
Console.WriteLine(di.Name);
Now, this works fine when the server doesnt have a password set on the
guest account.
In other cases, it gives the following runtime exception:
Unhandled Exception: System.IO.IOException: Logon failure: unknown user
name or bad password.
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.Directory.InternalGetFileDirectoryNames(..blah blah blah)
If I know the password to access the shares of the server, how do I set
them in my program?
I would be grateful to anyone who could guide me towards solving this
problem.
Thanks
I am trying to get a list of shared files and subdirectories in a
particular folder on a server.
For this I am using DirectoryInfo in the following way.
DirectoryInfo folder = new
DirectoryInfo("\\\\server_name\\shared_folder_name");
FileInfo[] fiArr = folder.GetFiles();
DirectoryInfo[] diArr = folder.GetDirectories();
foreach (FileInfo fri in fiArr)
Console.WriteLine(fri.Name);
foreach (DirectoryInfo di in diArr)
Console.WriteLine(di.Name);
Now, this works fine when the server doesnt have a password set on the
guest account.
In other cases, it gives the following runtime exception:
Unhandled Exception: System.IO.IOException: Logon failure: unknown user
name or bad password.
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.Directory.InternalGetFileDirectoryNames(..blah blah blah)
If I know the password to access the shares of the server, how do I set
them in my program?
I would be grateful to anyone who could guide me towards solving this
problem.
Thanks