Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用c#vs2010 windows 8中的管理类共享文件夹_C#_Visual Studio 2010_Windows 8_Directory_Share - Fatal编程技术网

使用c#vs2010 windows 8中的管理类共享文件夹

使用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

我需要在运行windows8的计算机上使用C#在VS2010中以编程方式共享文件夹。网络上有很多解决方案,我使用了管理类中描述的解决方案。我的机器坏了。我认为对于Windows8来说,这个过程可能有点不同。我正在试图找出我的代码中的问题,直到那时如果我想得到一些帮助,就会节省很多时间。代码返回一个拒绝访问错误。请帮忙

这是我正在使用的代码:

ManagementClass ManagementClass=新的ManagementClass(“Win32_共享”)

}

        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.");

        }