2
我正在研究.NET类,它将用于管理我们的Active Directory帐户的工具。我们的每个帐户都有一个网络主目录,根据我们正在使用的帐户类型,它可以位于两台不同的服务器上。如何共享远程文件夹?
我可以创建和删除文件夹就好了,但我遇到了共享文件夹的麻烦。 I found some code here这似乎是我想要的,但它不适合我。我得到的返回值是2,但我不确定那是什么表示。
这不应该是文件权限问题,因为我以我自己的方式运行我的测试应用程序,并且我完全控制了要共享的文件夹(及其每个父文件夹)。
这里是代码的我(修改)版本:
char[] delim = { '\\' };
// folderPath is a string (UNC path)
string[] drivePath = folderPath.Split(delim);
// Create a ManagementClass object
ManagementClass managementClass = new ManagementClass("Win32_Share");
// Create ManagementBaseObjects for in and out parameters
ManagementBaseObject inParams =
managementClass.GetMethodParameters("Create");
ManagementBaseObject outParams;
// Set the input parameters
inParams["Description"] = "";
inParams["Name"] = drivePath[3];
inParams["Path"] = folderPath;
inParams["Type"] = 0x0; // Disk Drive
// Invoke the method on the ManagementClass object
outParams = managementClass.InvokeMethod("Create", inParams, null);
我试过输出等outParams,但它看起来像返回值是我得到的。
有没有不同的方式来共享远程文件夹,可以更好地工作?