0
我一直试图绕过试图创建一个外部机器,驻留在同一网络上的一个文件夹导致的未经授权的访问,我已经尝试通过添加一个accessrule ,这并没有帮助我仍然得到同样的错误。认证用户创建目录在c#
String thepath = @"\\WONEATEMPMACHINE\C\ExampleData\"
DirectoryInfo dInfo = new DirectoryInfo(thepath);
DirectorySecurity dSecurity = dInfo.GetAccessControl();
dSecurity.AddAccessRule(new FileSystemAccessRule("DOMAINEXAMPLE\\wonea",
FileSystemRights.Write,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
PropagationFlags.None,
AccessControlType.Allow));
dInfo.SetAccessControl(dSecurity);
Directory.CreateDirectory(thepath + "\\newfolder");
感谢您的洞察力,我又看了一下应用程序的部署位置,并意识到它是供内部使用的。所以我打开了启用写入的文件夹给网络上使用的用户组,而不是通过软件以超灵活的方式进行。 – wonea 2010-11-24 12:00:56