UNC paths from drive mappings

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?
 
B

Bryan Phillips

Use the DriveInfo class:

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

DriveType will equal "Network" for mapped drives.
 
B

Bryan Phillips

I would avoid using p/invoke if you can, but I break this same rule when
I have to do so.
 

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

Top