Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 712325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:50:08+00:00 2026-05-14T04:50:08+00:00

here is my code it shares the folder but that does not work correctly

  • 0

here is my code it shares the folder but that does not work correctly when i want to access it , it shows access denied help required,

private static void ShareFolder(string FolderPath, string ShareName, string Description)
    {
        try
        {
            // Create a ManagementClass object
            ManagementClass managementClass = new ManagementClass("Win32_Share");
            // Create ManagementBaseObjects for in and out parameters
            ManagementBaseObject inParams = managementClass.GetMethodParameters("Create");
            ManagementBaseObject outParams;
            // Set the input parameters
            inParams["Description"] = Description;
            inParams["Name"] = ShareName;
            inParams["Path"] = FolderPath;
            inParams["Type"] = 0x0; // Disk Drive
            //Another Type:
            //DISK_DRIVE = 0x0;
            //PRINT_QUEUE = 0x1;
            //DEVICE = 0x2;
            //IPC = 0x3;
            //DISK_DRIVE_ADMIN = 0x80000000;
            //PRINT_QUEUE_ADMIN = 0x80000001;
            //DEVICE_ADMIN = 0x80000002;
            //IPC_ADMIN = 0x8000003;
            //inParams["MaximumAllowed"] = int maxConnectionsNum;
            // Invoke the method on the ManagementClass object
            outParams = managementClass.InvokeMethod("Create", inParams, null);
            // Check to see if the method invocation was successful

            if ((uint)(outParams.Properties["ReturnValue"].Value) != 0)
            {
                throw new Exception("Unable to share directory. Because Directory is already shared or directory not exist");
            }//end if

        }//end try
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message, "error!");
        }//end catch
    }//End Method
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:50:09+00:00Added an answer on May 14, 2026 at 4:50 am

    You have to add permissions to the shared folders. This post Adding Permissions to a shared folder using WMI and Microsoft .Net explains the steps in detail.

    Excerpt from the post

    To assign permission to the user, the
    following needs to be done

    1. Get hold of the Shared folder object’s setting and extract its
      security descriptor.
    2. Extract Access Control List (ACL) from the security descriptor.
    3. Get hold of the user account object and extract its security
      descriptor.
    4. Create a Windows Trustee object for the user using its security
      descriptor.
    5. Create an Access Control Entry (ACE) using the Trustee object.
    6. Add Access Control Entry to Access Control List.
    7. Assign List back to Security Descriptor for the folder
    8. Reassign security descriptor to the shared folder.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The script is on jsfiddle here : CODE What it does at the moment
Here is code from MSDN . I don't understand why the work isn't just
I want to open a txt file and read from it here's the code:
I have a program that does different things my questions is related to access
Ok the error is showing up somewhere in this here code if($error==false) { $query
Here is code my jqgrid editing through form. $(#DataEnergy).jqGrid('navGrid', '#pagergrid', {}, //options {editdata: {
Here my code, I need to insert into mysql database I have mysql,php,android 1)
Here a code to demonstrate an annoying problem: class A { public: A(): m_b(1),
here is code for regular expression matching #include<iostream> #include<stdio.h> #include<string.h> using namespace std; int
Here is code example class A{ int i; public: A(int i) : i(i) {}

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.