Home > Net >  Access to the local network path on the Shared folder
Access to the local network path on the Shared folder

Time:09-23

How can local have a Shared folder, according to his local path for network path

CodePudding user response:

Wmi is a kind of way:
C: \ & gt; Wmic path Win32_Share

In c # is:
 static string GetShareName (string localPath) 
{
Var escapedPath=localPath. Replace (@ \ ""," @ "\ ");
Var name=default (string);
Using (var a searcher=new ManagementObjectSearcher (" \ \ root \ \ CIMV2, "$" select the Name from Win32_Share where Path=" {escapedPath} \ ""))
Using (var items=a searcher. The Get ())
{
The foreach (var item in the items)
{
Name=name?? The Convert. ToString (item/" Name ");
Item. The Dispose ();
}
}
return name;
}
  •  Tags:  
  • C #
  • Related