471,334 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,334 software developers and data experts.

Sharing windows folder

All,

How do I share Windows folder programatically? Which namespace/class to look
for?

Thanks in advance for your help.

regards,
Anand
Jan 18 '06 #1
1 1224

"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.
Jan 18 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by BPearson | last post: by
reply views Thread by Henrik Gøttig | last post: by
1 post views Thread by bruce.1 | last post: by
8 posts views Thread by Kissi Asiedu | last post: by
5 posts views Thread by Gregory Gadow | last post: by
8 posts views Thread by antonyliu2002 | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.