My 'share folder' code is below:
string strServer = @"ServerName";
string strShareFolder = @"D:\DD";
string strShareName = @"MS_Test";
string strShareDesc = @"Share to store";
EnCryptDecrypt.Share.ADSI_Net.NetApi32.NetError nRetVal = 0;
AD_ShareUtil shUtil = new AD_ShareUtil();
nRetVal = shUtil.CreateShare(strServer, strShareFolder, strShareName, strShareDesc, false);
if (nRetVal == EnCryptDecrypt.Share.ADSI_Net.NetApi32.NetError.NERR_Success)
{
Console.WriteLine("Share {0} created", strShareName);
}
else if (nRetVal == EnCryptDecrypt.Share.ADSI_Net.NetApi32.NetError.NERR_DuplicateShare)
{
Console.WriteLine("Share {0} already exists", strShareName);
}
else
Console.WriteLine("Share not created", strShareName);
String directory = @"D:\DD";
DirectorySecurity sec = Directory.GetAccessControl(directory);
NTAccount acct = new NTAccount("Everyone");
IdentityReference id = acct.Translate(typeof(NTAccount));
FileSystemAccessRule rule = new FileSystemAccessRule(acct, FileSystemRights.ListDirectory, AccessControlType.Allow);
sec.AddAccessRule(rule);
Directory.SetAccessControl(directory, sec);
I need to add a text file to a 'share folder' on the server.
The above code is fine when running to create a 'share folder' in the server.
When I open the network share folder in another machine, then it is open folder,
but do not open the file into that share folder.
Message shows 'Access denied'.
How can I access the file in that remote share folder?
Please help appreciated.