Results 1 to 14 of 14

Thread: Creating shared folders and specifying share permissions

Hybrid View

  1. #1

    Thread Starter
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Creating shared folders and specifying share permissions

    Could not post the contents here as it is too long for the post size limit, so I've attached the 2 vb files to this post.

    See "Attached Files" section at the bottom of this post for my classes that make use of the NetShareAdd Windows API (and a couple of others) - just add them both to your project and then you can use my simple .NET wrapper as shown in the previous post Of course you can also just use them to see how the APIs are defined and used etc and make your own .NET versions.

    EDIT: New version of SharedFolder class uploaded that now allows you to create a share on a remote machine. There is now an optional argument for the SharedFolder.ShareExistingFolder method where you can specify the remote machine name - do not use "\\ServerName", just "ServerName" will do it.
    If you want to create the share locally then just either miss this argument off or specify Nothing for it.

    Here is an example of sharing the folder D:\Shared as "Shared Folder" on a remote server called TestServer:
    vb Code:
    1. SharedFolder.ShareExistingFolder("Shared Folder", "This is an example comment", "D:\Shared", PermissionsList, "TestServer")

    Note that I have included this functionality (along with a load of other Windows API based functions) in my Windows API library, which you can download for free here: http://cjwdev.wordpress.com/2010/07/...pack-released/
    Attached Files Attached Files
    Last edited by chris128; Jul 13th, 2010 at 05:24 PM.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  2. #2
    New Member
    Join Date
    May 2014
    Posts
    12

    Re: Creating shared folders and specifying share permissions

    Quote Originally Posted by chris128 View Post
    Could not post the contents here as it is too long for the post size limit, so I've attached the 2 vb files to this post.

    See "Attached Files" section at the bottom of this post for my classes that make use of the NetShareAdd Windows API (and a couple of others) - just add them both to your project and then you can use my simple .NET wrapper as shown in the previous post Of course you can also just use them to see how the APIs are defined and used etc and make your own .NET versions.

    EDIT: New version of SharedFolder class uploaded that now allows you to create a share on a remote machine. There is now an optional argument for the SharedFolder.ShareExistingFolder method where you can specify the remote machine name - do not use "\\ServerName", just "ServerName" will do it.
    If you want to create the share locally then just either miss this argument off or specify Nothing for it.

    Here is an example of sharing the folder D:\Shared as "Shared Folder" on a remote server called TestServer:
    vb Code:
    1. SharedFolder.ShareExistingFolder("Shared Folder", "This is an example comment", "D:\Shared", PermissionsList, "TestServer")

    Note that I have included this functionality (along with a load of other Windows API based functions) in my Windows API library, which you can download for free here: http://cjwdev.wordpress.com/2010/07/...pack-released/

    Hi Chris

    I have enjoyed to use your functions and can use them in VS 2013 without any problems - great!

    I have one question - is there any way that I can check if the folder is already shared before trying to share it? I get the NERR_DuplicateShare as result and it actually mess up the share so... not good.

    Thx for sharing your work - great job.

    /Mogge

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width