"Anand G" <an****@hp.com> wrote in message
news:43******@usenet01.boi.hp.com...
| All,
|
| How do I share Windows folder programatically? Which namespace/class to
look
| for?
|
| Thanks in advance for your help.
|
| regards,
| Anand
|
|
System.Management and the WMI class Win32_Share.
Following is a sample, that exports c:\\temp as Testshare...
public enum SharedDevice{
Disk = 0,
PrintQueue = 1,
Device = 2,
IPC = 3
}
....
using (ManagementClass o = new ManagementClass("root\\cimv2",
"Win32_Share", null))
{
ManagementBaseObject inputArgs = o.GetMethodParameters("Create");
inputArgs["Name"] = "Testshare";
inputArgs["Path"] = "c:\\temp";
inputArgs["Description"] = "This is public test share";
inputArgs["Type"] = SharedDevice.Disk;
ManagementBaseObject outParams = o.InvokeMethod("Create", inputArgs,
null);
uint ret = (uint)(outParams.Properties["ReturnValue"].Value);
if(ret != 0)
// handle failure....
}
}
Willy.