【发布时间】:2009-11-23 14:16:28
【问题描述】:
我正在 VS2008 中进行部署项目,在安装流程结束时,我需要创建一个共享文件夹,该文件夹对可从公司域访问的本地计算机上的每个人具有完全控制权限。 我成功创建了共享文件夹,但每个人都有读取权限。 任何有关如何执行此操作的帮助将不胜感激。
谢谢你, 瓦莱里乌
【问题讨论】:
标签: c# deployment-project
我正在 VS2008 中进行部署项目,在安装流程结束时,我需要创建一个共享文件夹,该文件夹对可从公司域访问的本地计算机上的每个人具有完全控制权限。 我成功创建了共享文件夹,但每个人都有读取权限。 任何有关如何执行此操作的帮助将不胜感激。
谢谢你, 瓦莱里乌
【问题讨论】:
标签: c# deployment-project
我假设您使用的是 ManagementClass 到 create a shared folder。
设置ManagementBaseObject 的访问字段应该让每个人都可以完全控制:
ManagementClass mc = new ManagementClass("win32_share");
ManagementBaseObject inParams = mc.GetMethodParameters("Create");
inParams["Description"] = "Shared Folder";
// ... whathever ...
inParams["Access"] = null; // <-- should give full control access to everyone
如果上述方法不起作用,您可能想尝试使用 smt 显式设置安全级别,如下所示:
public static void AddDirectorySecurity(string FileName, string Account, FileSystemRights Rights, AccessControlType ControlType)
{
DirectoryInfo dInfo = new DirectoryInfo(FileName);
DirectorySecurity dSecurity = dInfo.GetAccessControl();
// Add the FileSystemAccessRule to the security settings.
dSecurity.AddAccessRule(new FileSystemAccessRule(Account,
Rights,
ControlType));
// Set the new access settings.
dInfo.SetAccessControl(dSecurity);
}
如果以上都没有帮助,那么我建议您发布您的代码。
【讨论】: