This code needs to be performed for my work.
string filePath = "\\\\192.168.7.202\\Sample\sample.log"
var accessControlList = Directory.GetAccessControl( filePath );
Unfortunately, this code can't work without a Network Credentials. so the Network Credential for 192.168.7.202 has to be added on a computer I use.
Can anyone know how to add Netowrk Credentials by C# script, with its IP Address, Username, and Password?
This is my code, but doesn't work.....
string ipAddress = "192.168.7.202";
string username = "Administrator";
string password = "abcd";
NetworkCredential netCredential = new NetworkCredential(username, password, ipAddress);
CredentialCache theNetCache = new CredentialCache();
theNetCache.Add("192.168.7.202", 3389, "Basic", netCredential);
string filePath = "\\\\192.168.7.202\\Sample\sample.log"
var accessControlList = Directory.GetAccessControl( filePath ); **//Error occur without Credential**
May not have to keep the Credential permanently, at least need it for the Directory.GetAccessControl(filePath).
Can anyone give me a solution please...?
FYI, adding Credential of 192.168.7.202 to the Red box by myself makes Directory.GetAccessControl works well. Hope I can do it on C# script..