How to create a share programmatically in Vista?
- From: t.w.wetzel@xxxxxxxxxxxxxx
- Date: Sat, 25 Apr 2009 12:26:23 -0700 (PDT)
Hi,
I want to create a share on a Vista computer so that everybody has
full access to the share.
How can I do this?
This code only gives everybody the permission to read the share:
using(System.Management.ManagementClass Win32Share = new
ManagementClass("Win32_Share"))
using(System.Management.ManagementBaseObject parameters =
Win32Share.GetMethodParameters("Create"))
{
parameters["Name"] = "ShareName";
parameters["Path"] = "c:\\Temp";
parameters["Type"] = 0;
parameters["Access"] = null;
parameters["Description"] ="Shared programatically from WMI";
parameters["MaximumAllowed"] = 5;
using(System.Management.ManagementBaseObject result =
Win32Share.InvokeMethod("Create", parameters, null))
{
if (((uint)result["ReturnValue"]) == 0)
{
MessageBox.Show("Folder shared");
}
else
{
MessageBox.Show("Folder share failed");
}
}
}
Thank you
Thomas
.
- Prev by Date: Re: Threading a server
- Next by Date: Re: Application.DoEvents() resets cursor?
- Previous by thread: Capture image of App#A's window from App#B
- Next by thread: How to get data from datatable to dataset to use in report viewer ?
- Index(es):