Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Canonicalize a path (not a URL)

Canonicalize a path (not a URL)

Scheduled Pinned Locked Moved C#
csharpc++comlinuxalgorithms
8 Posts 3 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    James R Twine
    wrote on last edited by
    #1

    Hey all... I am working with .NET 1.1(!) and I am trying to find a method that canonicalizes a filesystem path.  Basically the .NET equivilent of the Win32 Shell API function PathCanonicalize(...).    What I need to do is convert a path like:

    C:\Program Files\Company\App\User1\Data\Res**\..\..\..\**User2\Data\Media

    To:

    C:\Program Files\Company\App\User2\Data\Media

    I am sure I can write code to do it (I had to in C++ before to get around the shell functions' MAX_PATH limit), but want to know if a method exists.    Searching for "Canonicalize" in the MSDN help and in this forum does not yield anything useful.    Adva_[Thanks]_nce!    Peace!

    -=- James
    Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
    Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
    See DeleteFXPFiles

    K V 2 Replies Last reply
    0
    • J James R Twine

      Hey all... I am working with .NET 1.1(!) and I am trying to find a method that canonicalizes a filesystem path.  Basically the .NET equivilent of the Win32 Shell API function PathCanonicalize(...).    What I need to do is convert a path like:

      C:\Program Files\Company\App\User1\Data\Res**\..\..\..\**User2\Data\Media

      To:

      C:\Program Files\Company\App\User2\Data\Media

      I am sure I can write code to do it (I had to in C++ before to get around the shell functions' MAX_PATH limit), but want to know if a method exists.    Searching for "Canonicalize" in the MSDN help and in this forum does not yield anything useful.    Adva_[Thanks]_nce!    Peace!

      -=- James
      Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
      Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
      See DeleteFXPFiles

      K Offline
      K Offline
      Kjetil Svendsen
      wrote on last edited by
      #2

      Hi. Long time since 1.1. Have you tried the DirectoryInfo object ?

      DirectoryInfo di = new DirectoryInfo(@"C:\Program Files\Company\App\User1\Data\Res\..\..\..\User2\Data\Media");

      Then the di.FullName would give C:\Program Files\Company\App\User2\Data\Media Kjetil

      J 1 Reply Last reply
      0
      • K Kjetil Svendsen

        Hi. Long time since 1.1. Have you tried the DirectoryInfo object ?

        DirectoryInfo di = new DirectoryInfo(@"C:\Program Files\Company\App\User1\Data\Res\..\..\..\User2\Data\Media");

        Then the di.FullName would give C:\Program Files\Company\App\User2\Data\Media Kjetil

        J Offline
        J Offline
        James R Twine
        wrote on last edited by
        #3

        I think that will do it!    Thanks!    Peace!

        -=- James
        Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
        Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
        See DeleteFXPFiles

        1 Reply Last reply
        0
        • J James R Twine

          Hey all... I am working with .NET 1.1(!) and I am trying to find a method that canonicalizes a filesystem path.  Basically the .NET equivilent of the Win32 Shell API function PathCanonicalize(...).    What I need to do is convert a path like:

          C:\Program Files\Company\App\User1\Data\Res**\..\..\..\**User2\Data\Media

          To:

          C:\Program Files\Company\App\User2\Data\Media

          I am sure I can write code to do it (I had to in C++ before to get around the shell functions' MAX_PATH limit), but want to know if a method exists.    Searching for "Canonicalize" in the MSDN help and in this forum does not yield anything useful.    Adva_[Thanks]_nce!    Peace!

          -=- James
          Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
          Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
          See DeleteFXPFiles

          V Offline
          V Offline
          Vikram A Punathambekar
          wrote on last edited by
          #4

          This is what Path.GetPath() is there for (System.IO namespace). :)

          Cheers, Vikram.


          The hands that help are holier than the lips that pray.

          J 1 Reply Last reply
          0
          • V Vikram A Punathambekar

            This is what Path.GetPath() is there for (System.IO namespace). :)

            Cheers, Vikram.


            The hands that help are holier than the lips that pray.

            J Offline
            J Offline
            James R Twine
            wrote on last edited by
            #5

            No such method.  Perhaps you meant Path.Get_**Full**_Path(...)?    I am realizing that the documentation is lacking simple terms like "Canonicalize" unless it is talking about a URL... :doh:    Peace!

            -=- James
            Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
            Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
            See DeleteFXPFiles

            V 1 Reply Last reply
            0
            • J James R Twine

              No such method.  Perhaps you meant Path.Get_**Full**_Path(...)?    I am realizing that the documentation is lacking simple terms like "Canonicalize" unless it is talking about a URL... :doh:    Peace!

              -=- James
              Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
              Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
              See DeleteFXPFiles

              V Offline
              V Offline
              Vikram A Punathambekar
              wrote on last edited by
              #6

              Apologies, I meant GetFullPath. Still, I don't think that deserved a 1 :~ (not from you, obviously, but some random guy)

              Cheers, Vikram.


              The hands that help are holier than the lips that pray.

              J 1 Reply Last reply
              0
              • V Vikram A Punathambekar

                Apologies, I meant GetFullPath. Still, I don't think that deserved a 1 :~ (not from you, obviously, but some random guy)

                Cheers, Vikram.


                The hands that help are holier than the lips that pray.

                J Offline
                J Offline
                James R Twine
                wrote on last edited by
                #7

                That was me... I hit the "not helpful" button thinking it was separate from the normal rating/voting buttons on the bottom right of the message.    Sorry.    Peace!

                -=- James
                Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                See DeleteFXPFiles

                V 1 Reply Last reply
                0
                • J James R Twine

                  That was me... I hit the "not helpful" button thinking it was separate from the normal rating/voting buttons on the bottom right of the message.    Sorry.    Peace!

                  -=- James
                  Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                  Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                  See DeleteFXPFiles

                  V Offline
                  V Offline
                  Vikram A Punathambekar
                  wrote on last edited by
                  #8

                  Never mind :-D As you've probably found out, you can change your votes now with the .net version of CP.

                  Cheers, Vikram.


                  The hands that help are holier than the lips that pray.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups