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;
}