tags:

views:

125

answers:

1

Hi!

I use this code to share folder:

 Public Sub Share()
        Dim managementClass As New ManagementClass("Win32_Share")
        Dim inParams As ManagementBaseObject = managementClass.GetMethodParameters("Create")
        inParams("Description") = "My Description"
        inParams("Name") = "Share Name"
        inParams("Path") = "D:\Folder"
        inParams("Type") = &H0
        Dim outParams As ManagementBaseObject = managementClass.InvokeMethod("Create", inParams, Nothing)
        If Convert.ToUInt32(outParams.Properties("ReturnValue").Value) <> 0 Then MessageBox.Show("Unable to share directory.")
        MessageBox.Show("Shared folder successfully!")
    End 
Sub

Now what I want is to define user that can access to this folder through network? How I can do that?

Thanks!

+1  A: 

This blog entry explains how to set up permissions for a share:

http://blogs.msdn.com/helloworld/archive/2008/06/06/programmatically-configuring-permissions-on-a-share-in-c.aspx

The code is in C#, so it not be a problem to port it to VB.

Dave Cluderay