Create a folder share?

  • Thread starter Thread starter pnp
  • Start date Start date
Easy, Using System.Management classes....


using System.Management;
....

using (ManagementClass o = new ManagementClass("\\\\.\\root\\cimv2",
"Win32_Share", null))
{
string method = "create";
ManagementBaseObject inputArgs = o.GetMethodParameters(method);
inputArgs["Name"] = "SharedTemp"; // share as
inputArgs["Path"] = "c:\\temp"; // directory to share
inputArgs["Description"] = "this is public share";
inputArgs["Type"] = 0; // 0 = Disk share type
ManagementBaseObject outParams = o.InvokeMethod(method, inputArgs, null);
uint ret = (uint)(outParams.Properties["ReturnValue"].Value);
if(ret != 0)
Console.WriteLine("Failed {0}", ret);
}

Willy.
 
Back
Top