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 / C++ / MFC
  4. how to convert a directory path to a relative path to another directory

how to convert a directory path to a relative path to another directory

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
5 Posts 4 Posters 0 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.
  • H Offline
    H Offline
    HeartFriend
    wrote on last edited by
    #1

    for example: DirA = "c:\windows\system" DirB = "c:\private\doc" A realtive to B = ..\..\private\doc how to implement this? thanks in advance.

    R D J H 4 Replies Last reply
    0
    • H HeartFriend

      for example: DirA = "c:\windows\system" DirB = "c:\private\doc" A realtive to B = ..\..\private\doc how to implement this? thanks in advance.

      R Offline
      R Offline
      rrrado
      wrote on last edited by
      #2

      it is just simple strings game. remove starting part of the path which is identical for both paths, then count number of remaining folders (RF#) in path A. then relative path is "(../) x RF# / remaining part of path B". i'm curious what would you need this for :) sounds like school homeword but it's holiday now :)


      rrrado

      1 Reply Last reply
      0
      • H HeartFriend

        for example: DirA = "c:\windows\system" DirB = "c:\private\doc" A realtive to B = ..\..\private\doc how to implement this? thanks in advance.

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Use PathCommonPrefix().


        "One must learn from the bite of the fire to leave it alone." - Native American Proverb

        1 Reply Last reply
        0
        • H HeartFriend

          for example: DirA = "c:\windows\system" DirB = "c:\private\doc" A realtive to B = ..\..\private\doc how to implement this? thanks in advance.

          J Offline
          J Offline
          Jack Puppy
          wrote on last edited by
          #4

          PathRelativePathTo

          Painted on the side of a dog trainer's van: SIT HAPPENS

          1 Reply Last reply
          0
          • H HeartFriend

            for example: DirA = "c:\windows\system" DirB = "c:\private\doc" A realtive to B = ..\..\private\doc how to implement this? thanks in advance.

            H Offline
            H Offline
            HeartFriend
            wrote on last edited by
            #5

            thanks for all you guys :).

            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