UNC paths from drive mappings

  • Thread starter Thread starter JezB
  • Start date Start date
J

JezB

I can get a list of drive mappings via

Directory.GetLogicalDrives

but is there any way I can get the UNC path (eg. \\machine\sharename) for
those drives that are mapped to network shares?
 
Use the DriveInfo class:

foreach(DriveInfo drive in DriveInfo.GetDrives()){
Console.WriteLine(drive + " " + drive.DriveType);
}

DriveType will equal "Network" for mapped drives.
 
I would avoid using p/invoke if you can, but I break this same rule when
I have to do so.
 
Back
Top