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

Posted on 2009-02-24
Last Modified: 2013-12-17
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 ( that allow for that but I wanted to know if there was an easy way to do it in c#

Question by:SSAFECS
    LVL 10

    Accepted Solution

    .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.

    Author Closing Comment

    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
    LVL 10

    Expert Comment

    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

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Normally the drop down box control found in the .Net framework tools is able to select just one data and value at a time, which is displayed on the text area.   But what if you want to have multiple values to be selected in the drop down box? As …
    In my previous two articles we discussed Binary Serialization ( and XML Serialization ( In this article we will try to know more about SOAP (Simple Object Acces…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now