Hi
If you have set "Full Control" in security tab of your share folder,
then Add the FileSystemAccessRule to the security settings like this
string path = @"\\192.168.115.27\New\new2"; //I assume that: Your file server ip is 192.168.115.27
//you have shared the "New" folder and set Full control, then you want to create "new2" folder and add domain account for "new2" ACL
if (Directory.Exists(path))
{
return;
}
DirectoryInfo di = Directory.CreateDirectory(path);
DirectoryInfo dInfo = new DirectoryInfo(path);
// Get a DirectorySecurity object that represents the
// current security settings.
DirectorySecurity dSecurity = dInfo.GetAccessControl();
string domainName = "mydomain";
string identity = "myaccount";
// Add the FileSystemAccessRule to the security settings.
FileSystemAccessRule fsr = new FileSystemAccessRule(domainName + @"\" + identity,
System.Security.AccessControl.FileSystemRights.ReadData |
System.Security.AccessControl.FileSystemRights.WriteData |
System.Security.AccessControl.FileSystemRights.Modify,
AccessControlType.Allow);
dSecurity.AddAccessRule(fsr);
// Set the new access settings.
dInfo.SetAccessControl(dSecurity);