extract subdirectory name
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\' |
Re: extract subdirectory name
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 |
Re: extract subdirectory name
Thank you Der_Unwissende
Could you please give me an Exemple . |
Re: extract subdirectory name
Hi mijack,
try a combination of ExtractRelativePath and ExtractFilePath:
Delphi-Quellcode:
Regards
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; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:00 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