Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Relative Pfade (https://www.delphipraxis.net/28515-relative-pfade.html)

nailor 25. Aug 2004 17:44


Relative Pfade
 
Hi!

-------------------

Ich habe:

- "absoluter Pfad1"
- "absoluter Pfad2"

Ich will:

- realtiver Pfad von "absoluter Pfad1" nach "absoluter Pfad2"

-------------------

Ich habe:

- "absoluter Pfad1"
- "relativer Pfad1"

Ich will:

- absoluter Pfad von "relativer Pfad1", wenn ich von "absoluter Pfad1" ausgehe


-------------------

wie geht das am besten?

Mamphil 28. Aug 2004 17:56

Re: Relative Pfade
 
Hi!

Beispiel:
Pfad 1 : /mein/pfad/ist/geheim/
Pfad 2 : /mein/pfad/soll/frei/sein/

Im Prinzip musst du von vorne so weit gehen, wie beide Pfäde gleich sind. Also: Im Beispiel weißt du, dass /mein/pfad/ bei beiden gleich ist. Du musst also ersteinmal bis dorthin in der Hierarchie herunterklettern (Pfad 1 :arrow: Pfad 2 : ../../ | Pfad 2 :arrow: Pfad 1 : ../../../)

Und dann musst du nur noch den Rest-Pfad des jeweils anderen Pfades wieder anhängen, also "heraufklettern".

Mamphil

nailor 28. Aug 2004 18:17

Re: Relative Pfade
 
ich hab mittlerweile das
Zitat:

Delphi-Syntax:

function ExtractRelativePath(const BaseName, DestName: string): string;
hier gefunden. das ist schonmal ein schritt in die sehr richtige richtung.

Mamphil 28. Aug 2004 19:35

Re: Relative Pfade
 
:thumb: Wunderbar!
Aber: Warum einfach, wenn's auch kompliziert ginge? :mrgreen:

Mamphil

nailor 28. Aug 2004 20:27

Re: Relative Pfade
 
weil ich einfach nicht kannte. in die andere richtung werde ich jetzt auch nochmal die OH durchforsten


Alle Zeitangaben in WEZ +1. Es ist jetzt 00:13 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz