Displaying shared folders

  • Thread starter Thread starter Anil
  • Start date Start date
A

Anil

I need to know whether .Net provides methods/classes for displaying shared
folders of a device.
One way to solve this problem is to import Win32 dlls ,but is there a direct
way provided by .Net by which all the user level shared folders can be
displayed ?
 
Hi,

You can use the classes in System.Management namespace to query the
WIN32_Share class.

ManagementClass shareClass = new ManagementClass("Win32_Share");
ManagementObjectCollection shares = shareClass.GetInstances();
foreach (ManagementObject share in shares)
{
Console.WriteLine("{0} -> {1}", share["Name"], share["Path"]);
}

Hope this helps
 
Back
Top