Translate UNC path to local mounted driveletter.

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi

Are there any way in C# to translate a UNC path to a drive letter used on the local machine.

E.g.if my drive s: is mounted to \serverShared, then i would like to be able to feed a method with \serverSharedlibfile.ext and get in return s:libfile.ext.

My first idea was to use DriveInfo.GetDrives, iterate through each and see if they had some information. It doesnt seem like they hold any usefull information for this purpose.

Are there any other way to get this information? Performance in this exact situation is not very important, so iterating through some values to search for the first part of the UNC will be ok.

I hope someone has been here before, and can help me figure this out.

/Anders


View the full article
 
Back
Top