.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

List of Sharing Folder using C#.Net

Posted By: Narayanan     Posted Date: September 13, 2012    Points:5   Category :C#
Hi ,
How to check list of Share folders in the Local System using C#.Net and also User Permission (like Allow Network Users Changes this File(s)) ?

Author: Jack Hard          Accepted Answer   
Posted Date: September 14, 2012     Points: 40   

You can get a list of all the shared folders using the WMI Win32_Share and see if the folder you're looking for is between them. Here's a snippet that might help you with this:

public static List<string> GetSharedFolders()

List<string> sharedFolders = new List<string>();

// Object to query the WMI Win32_Share API for shared files...

ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from win32_share");

ManagementBaseObject outParams;

ManagementClass mc = new ManagementClass("Win32_Share"); //for local shares

foreach (ManagementObject share in searcher.Get()){

string type = share["Type"].ToString();

if (type == "0") // 0 = DiskDrive (1 = Print Queue, 2 = Device, 3 = IPH)
string name = share["Name"].ToString(); //getting share name

string path = share["Path"].ToString(); //getting share path

string caption = share["Caption"].ToString(); //getting share description



return sharedFolders;


Author: Narayanan             
Posted Date: September 25, 2012     Points: 20   

Hi ,
Thanks .It works.

Regards, Lakshmi Naraayanan.S

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend