http://www.dotnet247.com/247reference/msgs/11/56914.aspx

解决方案 »

  1.   

    问题解决
    private void setShare(String name, String path)
    {
    String sharename = "backupDBFile";
    UInt32 ret = Create("backupDBFile", 10, sharename, "",@path);
             share = new ManagementObject("Win32_Share=" + "'" + sharename +"'");
    }
    public static UInt32 Create(string Description, UInt32 MaximumAllowed, string Name, string Password, string Path)
    {
    ManagementBaseObject inParams = null;
    ManagementClass classObj = new System.Management.ManagementClass(null, "Win32_Share", null);
    inParams = classObj.GetMethodParameters("Create");
    inParams["Access"] = null; // default Security descriptor used
    inParams["Description"] = Description;
    inParams["MaximumAllowed"] = MaximumAllowed;
    inParams["Name"] = Name;
    inParams["Password"] = Password;
    inParams["Path"] = Path;
    inParams["Type"] = 0; // Disk drive 0, print queue 1
    ManagementBaseObject outParams = classObj.InvokeMethod("Create", inParams, null);
    return Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
    }