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 ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top