Groups | Blog | Home
all groups > dotnet faqs > march 2004 >

dotnet faqs : Displaying shared folders



Anil
3/26/2004 4:04:50 PM
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 ?



Chris Taylor
3/27/2004 3:33:36 PM
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

--
Chris Taylor
http://dotnetjunkies.com/WebLog/chris.taylor/
[quoted text, click to view]

AddThis Social Bookmark Button