Click here to Skip to main content
15,893,622 members
Home / Discussions / C#
   

C#

 
GeneralRe: A question about the ThreadPool class Pin
Marc Clifton15-Mar-03 5:57
mvaMarc Clifton15-Mar-03 5:57 
GeneralRe: A question about the ThreadPool class Pin
leppie15-Mar-03 7:23
leppie15-Mar-03 7:23 
GeneralRe: A question about the ThreadPool class Pin
Marc Clifton17-Mar-03 3:28
mvaMarc Clifton17-Mar-03 3:28 
GeneralRe: A question about the ThreadPool class Pin
Arun Bhalla17-Mar-03 16:55
Arun Bhalla17-Mar-03 16:55 
QuestionRelative and absolute path ? Pin
Chris Richner14-Mar-03 13:33
Chris Richner14-Mar-03 13:33 
AnswerRe: Relative and absolute path ? Pin
James T. Johnson14-Mar-03 17:46
James T. Johnson14-Mar-03 17:46 
GeneralRe: Relative and absolute path ? Pin
Chris Richner17-Mar-03 4:40
Chris Richner17-Mar-03 4:40 
GeneralRe: Relative and absolute path ? Pin
James T. Johnson17-Mar-03 15:02
James T. Johnson17-Mar-03 15:02 
Jerry Maguire wrote:
i have two absolute paths and like to have the relative path from path1 to path 2

Ok, I think the easiest thing to do is to break each part down (root, dir, dir, ..., filename) then you can start to remove the like parts one by one until they don't match.

path1 => "/foo/bar/baz/index.html"
path2 => "/foo/bar/stuff/kappa.html"
 
path1 breakdown:
  root = "/"
  dir = "foo", "bar", "baz"
  filename = "index.html"
 
path2 breakdown:
  root = "/"
  dir = "foo", "bar", "stuff"
  filename = "kappa.html"
Now to generate the relative path...

path1.root == path2.root so remove the root from the list
path1.dir[0] == path2.dir[0] so remove that from the list
path1.dir[1 (really 0 now)] == path2.dir[1 (ditto)] so remove that from the list
path1.dir[2 (really 0 now)] != path2.dir[2 (ditto)] so we can begin to piece together the relative path.

For each directory left in path1 you need to go up one directory (..) then append each of the directories left in path2.

If by chance you have found that all of the directories match then you just need to specify the filename. I'll work up some code then post it as a reply to this msg Wink | ;)

James

"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation

GeneralRe: Relative and absolute path ? Pin
James T. Johnson17-Mar-03 16:33
James T. Johnson17-Mar-03 16:33 
GeneralRe: Relative and absolute path ? Pin
Chris Richner18-Mar-03 9:30
Chris Richner18-Mar-03 9:30 
Generalconvert bitmap to bytes[] !!! Pin
Dalia14-Mar-03 10:08
Dalia14-Mar-03 10:08 
GeneralRe: convert bitmap to bytes[] !!! Pin
Anonymous14-Mar-03 10:31
Anonymous14-Mar-03 10:31 
GeneralRe: convert bitmap to bytes[] !!! Pin
Smitha Nishant14-Mar-03 14:05
protectorSmitha Nishant14-Mar-03 14:05 
GeneralRe: convert bitmap to bytes[] !!! Pin
Dalia15-Mar-03 10:59
Dalia15-Mar-03 10:59 
QuestionHow to update a richtextbox faster? Pin
14-Mar-03 8:24
suss14-Mar-03 8:24 
AnswerRe: How to update a richtextbox faster? Pin
James T. Johnson14-Mar-03 18:13
James T. Johnson14-Mar-03 18:13 
GeneralVS. NET bug Pin
Antoine Dubuc14-Mar-03 6:54
Antoine Dubuc14-Mar-03 6:54 
GeneralCustom Calender Pin
Mazdak14-Mar-03 5:19
Mazdak14-Mar-03 5:19 
GeneralRe: Custom Calender Pin
Paresh Gheewala28-May-03 10:58
Paresh Gheewala28-May-03 10:58 
Generalchecking the children of a node in a TreeView Pin
se99ts14-Mar-03 2:14
se99ts14-Mar-03 2:14 
GeneralFixed Pin
se99ts14-Mar-03 4:45
se99ts14-Mar-03 4:45 
GeneralRe: checking the children of a node in a TreeView Pin
Paresh Gheewala28-May-03 11:00
Paresh Gheewala28-May-03 11:00 
GeneralOpenFileDialog type in C# Pin
Member Salamon14-Mar-03 0:25
Member Salamon14-Mar-03 0:25 
GeneralRe: OpenFileDialog type in C# Pin
John Fisher14-Mar-03 7:30
John Fisher14-Mar-03 7:30 
GeneralRe: OpenFileDialog type in C# Pin
Member Salamon18-Mar-03 12:21
Member Salamon18-Mar-03 12:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.