以编程方式创建共享文件夹 C#
Creating a shared folder programmatically c#
我正在尝试使用以下代码在计算机管理共享中创建共享文件夹
ManagementClass managementClass = new ManagementClass("Win32_Share");
ManagementBaseObject inParams = managementClass.GetMethodParameters("Create");
ManagementBaseObject outParams;
inParams["Description"] = Description;
inParams["Name"] = ShareName;
inParams["Path"] = FolderPath;
inParams["Type"] = 0x0; // Disk Drive
outParams = managementClass.InvokeMethod("Create", inParams, null);
var res = (uint)(outParams.Properties["ReturnValue"].Value);
总是恢复 returns 2.
任何人都可以在这方面提供帮助吗?
it 2 是什么意思,所有其他输出参数是什么?
基于 Create method of Win32_Share documentation ,可能的 return 值为:
Success (0)
Access denied (2)
Unknown failure (8)
Invalid name (9)
Invalid level (10)
Invalid parameter (21)
Duplicate share (22)
Redirected path (23)
Unknown device or directory (24)
Net name not found (25)
Other (26–4294967295)
我正在尝试使用以下代码在计算机管理共享中创建共享文件夹
ManagementClass managementClass = new ManagementClass("Win32_Share");
ManagementBaseObject inParams = managementClass.GetMethodParameters("Create");
ManagementBaseObject outParams;
inParams["Description"] = Description;
inParams["Name"] = ShareName;
inParams["Path"] = FolderPath;
inParams["Type"] = 0x0; // Disk Drive
outParams = managementClass.InvokeMethod("Create", inParams, null);
var res = (uint)(outParams.Properties["ReturnValue"].Value);
总是恢复 returns 2.
任何人都可以在这方面提供帮助吗? it 2 是什么意思,所有其他输出参数是什么?
基于 Create method of Win32_Share documentation ,可能的 return 值为:
Success (0)
Access denied (2)
Unknown failure (8)
Invalid name (9)
Invalid level (10)
Invalid parameter (21)
Duplicate share (22)
Redirected path (23)
Unknown device or directory (24)
Net name not found (25)
Other (26–4294967295)