使用c#vs2010 windows 8中的管理类共享文件夹
我需要在运行windows8的计算机上使用C#在VS2010中以编程方式共享文件夹。网络上有很多解决方案,我使用了管理类中描述的解决方案。我的机器坏了。我认为对于Windows8来说,这个过程可能有点不同。我正在试图找出我的代码中的问题,直到那时如果我想得到一些帮助,就会节省很多时间。代码返回一个拒绝访问错误。请帮忙 这是我正在使用的代码: ManagementClass ManagementClass=新的ManagementClass(“Win32_共享”) }使用c#vs2010 windows 8中的管理类共享文件夹,c#,visual-studio-2010,windows-8,directory,share,C#,Visual Studio 2010,Windows 8,Directory,Share,我需要在运行windows8的计算机上使用C#在VS2010中以编程方式共享文件夹。网络上有很多解决方案,我使用了管理类中描述的解决方案。我的机器坏了。我认为对于Windows8来说,这个过程可能有点不同。我正在试图找出我的代码中的问题,直到那时如果我想得到一些帮助,就会节省很多时间。代码返回一个拒绝访问错误。请帮忙 这是我正在使用的代码: ManagementClass ManagementClass=新的ManagementClass(“Win32_共享”) } Manage
ManagementBaseObject inParams = managementClass.GetMethodParameters("Create");
ManagementBaseObject outParams;
inParams["Description"] = "Dump";
inParams["Name"] = "Dump";
inParams["Path"] = "D:\\Dump";
inParams["Type"] = 0x0; // Disk Drive
DirectoryInfo d = new DirectoryInfo("D:\\Dump");
if (d.Exists)
{
}
outParams = managementClass.InvokeMethod("Create", inParams, null);
// Check to see if the method invocation was successful
if ((uint)(outParams.Properties["ReturnValue"].Value) != 0)
{
throw new Exception("Unable to share directory.");
}