If I open up a File Explorer, and type \\somesite.com\d$ I will get prompted for credentials, and after entering them I get access to the file system. How can I do this in C# to access \\somesite.com\d$ to just see the files/directories in code?
Isn't there something baked into .NET that does this? The solutions I've found on Google want to import different .dlls and do the plumbing themselves...
I've tried this:
string username = "username";
string password = "password";
string domain = "domain";
NetworkCredential theNetworkCredential = new NetworkCredential(username, password, domain);
CredentialCache theNetCache = new CredentialCache();
theNetCache.Add(new Uri(@"\\somesite.com"), "Basic", theNetworkCredential);
string[] theFolders = System.IO.Directory.GetDirectories(@"\\somesite.com\d$");
But it says the username/password is incorrect. If I first go to the File Explorer and log in, and run the program again, it works fine.