Is there an easy way in csharp to take a UNC path and resolve its local path

In c#, is there an easy way to take a UNC and resolve its physical location, in other words I have the UNC path \\server\dir1\dir2 and I want to know that that UNC points to C:\dir1\dir2 returned?

I know in c++ there are certain libraries like this one (http://support.microsoft.com/kb/q148391/) that allow for that but I wanted to know if there was an easy way to do it in c#

thanx
SSAFECSAsked:
Who is Participating?
 
lucius_theCommented:
.NET doesn't necessarily recognize that the UNC path is local. I don't think there's a method in the Framework to do this, but you can do it yourself even though it won't be simple.

Idea guidelines:
- extract the computer name from your string and compare it with local computer name. If it scores a hit:
- get a collection of all shares on your computer, and find the sharename from your string, replace it with full path name of the share

I can't exactly tell you how to do it right away, it's just an idea that might work.
0
 
SSAFECSAuthor Commented:
Yea i wound up enumerating the share's via P/Invoke and doing a comparison i just wanted to make sure there wasn't a faster way
0
 
lucius_theCommented:
Well, maybe there still is a better way... you and I just don't know of it :)
I think this is good, anyway, it sounds like a correct way to go about this problem. Thanks for the points
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.