locked
relative path RRS feed

  • Question

  • Hi All,

    I would like to know that is there anyway to get relative path ?

    For example , if call IvsHierarchy.getcanonicalname(...) , it gives compleate path like  c:\d1\d2\file.txt.

    Bout I would like to get  like ../../file.txt. Is there anyway to do it ? 

    Monday, November 3, 2014 5:57 AM

Answers

  • Hi,

    Neither the native IVSHierarchy nor the automation EnvDTE.ProjectItem seem to offer a property to get the relative path of a file to the path of its parent project, so:

    1) First, think if your requirement is really needed. Why do you need a relative path?

    2) If it's really needed, use the methods provided by .NET to get a relative path. See for example:

    How to get relative path from absolute path
    http://stackoverflow.com/questions/275689/how-to-get-relative-path-from-absolute-path


    * My new blog about VSX: http://www.visualstudioextensibility.com * Twitter: https://twitter.com/VSExtensibility * MZ-Tools productivity extension for Visual Studio: http://www.mztools.com.

    • Proposed as answer by Carlos J. Quintero Monday, November 3, 2014 11:36 AM
    • Marked as answer by Caillen Monday, November 17, 2014 1:29 AM
    Monday, November 3, 2014 11:36 AM