title: How to share a folder on Windows 7
body: <p>I am using C# to create a folder and share it on the network:</p>
  
  <pre><code>if (!System.IO.Directory.Exists(FolderPath))
  {
        System.IO.Directory.CreateDirectory(FolderPath);
        // Calling Win32_Share class to create a shared folder
        ManagementClass managementClass = new ManagementClass("Win32_Share");
        // Get the parameter for the Create Method for the folder
        ManagementBaseObject inParams = managementClass.GetMethodParameters("Create");
        ManagementBaseObject outParams;
        // Assigning the values to the parameters
        inParams["Description"] = Description;
        inParams["Name"] = ShareName;
        inParams["Path"] = FolderPath;
        inParams["Type"] = 0x0;
        // Finally Invoke the Create Method to do the process
        outParams = managementClass.InvokeMethod("Create", inParams, null);
        // Validation done here to check sharing is done or not
        if ((uint)(outParams.Properties["ReturnValue"].Value) != 0)
        {
             //MessageBox.Show("Folder might be already in share or unable to share the directory");
        }
  }
  </code></pre>
  
  <p>It works on XP, but I am not able to share a folder from this code on Windows 7.</p>
  
  <p>Can anyone tell me how I can share a folder in Windows 7 using C#?</p>