Access shared network folder using credentials
Rajesh Ambakkat
216
Reputation points
I am trying to access a network drive from code using credentials. I tried to use the following code, it seems to be not working
NetworkCredential theNetworkCredential = new NetworkCredential(equipment.User, equipment.Password);
CredentialCache theNetCache = new CredentialCache();
theNetCache.Add(new Uri(equipment.SourceFolder), "Basic", theNetworkCredential);
string[] theFiles = Directory.GetFiles(equipment.SourceFolder);
Is there any way we can access it with other machines account (folder is shared from this machine).