How can I get the names of shared folders in a host ?

  • Thread starter Thread starter Scherbina Vladimir
  • Start date Start date
You can use the System.Management library (WMI).

ManagementClass objClass = new
ManagementClass("\\\\eurodevssq001\\root\\cimv2:Win32_Share");
foreach(ManagementObject objShare in objClass.GetInstances()) {
Console.WriteLine(string.Format("{0} -> {1}",
objShare.Properties["Name"].Value, objShare.Properties["Path"].Value));
}

Check the docs for the Win32_Share management class for other types of
information about the share.


Arild
 
Forgot to mention that you replace "eurodevssq001" with whatever server you
want to enumerate shares on.

Arild

Arild Bakken said:
You can use the System.Management library (WMI).

ManagementClass objClass = new
ManagementClass("\\\\eurodevssq001\\root\\cimv2:Win32_Share");
foreach(ManagementObject objShare in objClass.GetInstances()) {
Console.WriteLine(string.Format("{0} -> {1}",
objShare.Properties["Name"].Value, objShare.Properties["Path"].Value));
}

Check the docs for the Win32_Share management class for other types of
information about the share.


Arild

Scherbina Vladimir said:
is there any function to get the names of shared folders ?
 
Arild Bakken said:
Forgot to mention that you replace "eurodevssq001" with whatever server you
want to enumerate shares on.
No problem, I understood. Thanks.
Arild

Arild Bakken said:
You can use the System.Management library (WMI).

ManagementClass objClass = new
ManagementClass("\\\\eurodevssq001\\root\\cimv2:Win32_Share");
foreach(ManagementObject objShare in objClass.GetInstances()) {
Console.WriteLine(string.Format("{0} -> {1}",
objShare.Properties["Name"].Value, objShare.Properties["Path"].Value));
}

Check the docs for the Win32_Share management class for other types of
information about the share.


Arild

Scherbina Vladimir said:
is there any function to get the names of shared folders ?
 
Back
Top