AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

extract subdirectory name

Ein Thema von mijack · begonnen am 19. Mai 2007 · letzter Beitrag vom 19. Mai 2007
Antwort Antwort
mijack

Registriert seit: 18. Mai 2007
11 Beiträge
 
Delphi 2007 Enterprise
 
#1

extract subdirectory name

  Alt 19. Mai 2007, 16:09
let's suppose this :


Delphi-Quellcode:
[b]Label1.caption :='c:\Folfer1\file1'[/b]

i want to dispaly :

label2.caption:=File1 label3.caption:=' nothing to display '


[b]Label1.caption :='c:\Folder1\Folder2\file1'[/b]

i want to dispaly :

label2.caption:=File1 label3.caption:='repertoire2\'
  Mit Zitat antworten Zitat
Der_Unwissende

Registriert seit: 13. Dez 2003
Ort: Berlin
1.756 Beiträge
 
#2

Re: extract subdirectory name

  Alt 19. Mai 2007, 16:19
Hi,
what about using some kind of Tokenizer (e.g. split). Just split the input by the PathSeperator, which will return a Stringlist containing one entry per directory (and of course the file). So the first entry will be the drive, the second one contains the "main"-directory, the last one will contain the fileName, the entrys beetween the second and last one are subfolders.

Regards Der Unwissende
  Mit Zitat antworten Zitat
mijack

Registriert seit: 18. Mai 2007
11 Beiträge
 
Delphi 2007 Enterprise
 
#3

Re: extract subdirectory name

  Alt 19. Mai 2007, 16:37
Thank you Der_Unwissende

Could you please give me an Exemple .
  Mit Zitat antworten Zitat
Hawkeye219

Registriert seit: 18. Feb 2006
Ort: Stolberg
2.227 Beiträge
 
Delphi 2010 Professional
 
#4

Re: extract subdirectory name

  Alt 19. Mai 2007, 16:48
Hi mijack,

try a combination of Delphi-Referenz durchsuchenExtractRelativePath and Delphi-Referenz durchsuchenExtractFilePath:

Delphi-Quellcode:
var
  s, t : string;
begin
  s := 'c:\Folder1\file1';
  t := ExtractRelativePath('c:\Folder1\', ExtractFilePath(s)); // -> t = ''

  s := 'c:\Folder1\Folder2\file1';
  t := ExtractRelativePath('c:\Folder1\', ExtractFilePath(s)); // -> t = 'Folder2\'
end;
Regards
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:39 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