AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Verzeichnislisting als Baumansicht in StringListe
Thema durchsuchen
Ansicht
Themen-Optionen

Verzeichnislisting als Baumansicht in StringListe

Offene Frage von "Luckie"
Ein Thema von Luckie · begonnen am 16. Jul 2012 · letzter Beitrag vom 16. Jul 2012
 
Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#1

Verzeichnislisting als Baumansicht in StringListe

  Alt 16. Jul 2012, 10:38
Ich durchsuche ein Verzeichnis mit FindFirst und schreibe das Ergebnis in eine StringListe:
Delphi-Quellcode:
procedure TDTListDir.FindFiles(RootFolder: AnsiString; Mask: AnsiString = '*.*'; Recurse: Boolean = True);
var
  SR: TSearchRec;
begin
  RootFolder := IncludeTrailingPathDelimiter(RootFolder);

  if Recurse then
    if FindFirst(RootFolder + '*.*', faAnyFile, SR) = 0 then
    try
      repeat
        if SR.Attr and faDirectory = faDirectory then
          if (SR.Name <> '.') and (SR.Name <> '..') then
            FindFiles(RootFolder + SR.Name, Mask, Recurse);
      until FindNext(SR) <> 0;
    finally
      FindClose(SR);
    end;
  if FindFirst(RootFolder + Mask, faAnyFile, SR) = 0 then
  try
    repeat
      if SR.Attr and faDirectory <> faDirectory then
      begin
        sl.Add(RootFolder + SR.Name + Format('(%d, %s)',
        [SR.Size, FormatDateTime('yyyy-mm-dd hh:nn:ss',FileDateToDateTime(SR.Time))]));
      end;
    until FindNext(SR) <> 0;
  finally
    FindClose(SR);
  end;
end;
Das Ergebnis sieht dann so aus:
Code:
C:\Users\Michael\Documents\Borland Studio-Projekte\__history\Unit1.dfm.~1~(606, 2012-04-20 22:35:10)
C:\Users\Michael\Documents\Borland Studio-Projekte\__history\Unit1.pas.~10~(2593, 2012-04-20 23:03:16)
C:\Users\Michael\Documents\Borland Studio-Projekte\__history\Unit1.pas.~1~(2205, 2012-04-20 22:37:30)
C:\Users\Michael\Documents\Borland Studio-Projekte\__history\Unit1.pas.~2~(2234, 2012-04-20 22:41:12)
C:\Users\Michael\Documents\Borland Studio-Projekte\__history\Unit1.pas.~3~(2608, 2012-04-20 22:49:04)
C:\Users\Michael\Documents\Borland Studio-Projekte\__history\Unit1.pas.~4~(2618, 2012-04-20 22:51:00)
C:\Users\Michael\Documents\Borland Studio-Projekte\__history\Unit1.pas.~5~(2622, 2012-04-20 22:55:58)
C:\Users\Michael\Documents\Borland Studio-Projekte\__history\Unit1.pas.~6~(2622, 2012-04-20 22:57:18)
C:\Users\Michael\Documents\Borland Studio-Projekte\__history\Unit1.pas.~7~(2613, 2012-04-20 22:58:18)
C:\Users\Michael\Documents\Borland Studio-Projekte\__history\Unit1.pas.~8~(2609, 2012-04-20 22:58:38)
C:\Users\Michael\Documents\Borland Studio-Projekte\__history\Unit1.pas.~9~(2609, 2012-04-20 23:02:56)
C:\Users\Michael\Documents\Borland Studio-Projekte\__history\Unit2.dfm.~1~(854, 2012-05-09 17:52:44)
C:\Users\Michael\Documents\Borland Studio-Projekte\__history\Unit2.dfm.~2~(979, 2012-05-09 17:53:10)
C:\Users\Michael\Documents\Borland Studio-Projekte\__history\Unit2.dfm.~3~(1073, 2012-05-09 17:58:12)
C:\Users\Michael\Documents\Borland Studio-Projekte\__history\Unit2.dfm.~4~(1422, 2012-05-09 18:04:12)
C:\Users\Michael\Documents\Borland Studio-Projekte\__history\Unit2.pas.~10~(2018, 2012-05-09 18:18:14)
C:\Users\Michael\Documents\Borland Studio-Projekte\__history\Unit2.pas.~11~(2013, 2012-05-09 18:19:50)
C:\Users\Michael\Documents\Borland Studio-Projekte\__history\Unit2.pas.~2~(873, 2012-05-09 17:56:48)
C:\Users\Michael\Documents\Borland Studio-Projekte\__history\Unit2.pas.~3~(873, 2012-05-09 17:57:38)
C:\Users\Michael\Documents\Borland Studio-Projekte\__history\Unit2.pas.~4~(1543, 2012-05-09 17:58:28)
C:\Users\Michael\Documents\Borland Studio-Projekte\__history\Unit2.pas.~5~(1951, 2012-05-09 18:06:32)
C:\Users\Michael\Documents\Borland Studio-Projekte\__history\Unit2.pas.~6~(1948, 2012-05-09 18:08:12)
C:\Users\Michael\Documents\Borland Studio-Projekte\__history\Unit2.pas.~7~(2006, 2012-05-09 18:09:32)
C:\Users\Michael\Documents\Borland Studio-Projekte\__history\Unit2.pas.~8~(2117, 2012-05-09 18:12:16)
C:\Users\Michael\Documents\Borland Studio-Projekte\__history\Unit2.pas.~9~(2006, 2012-05-09 18:14:48)
C:\Users\Michael\Documents\Borland Studio-Projekte\HTTPDownloadDemo.zip(316321, 2012-05-09 18:26:00)
C:\Users\Michael\Documents\Borland Studio-Projekte\Project1.bdsproj.local(99, 2012-06-18 13:36:28)
C:\Users\Michael\Documents\Borland Studio-Projekte\Project1.identcache(153, 2012-07-05 01:57:12)
C:\Users\Michael\Documents\Borland Studio-Projekte\Project2.bdsproj(8473, 2012-05-09 18:10:06)
C:\Users\Michael\Documents\Borland Studio-Projekte\Project2.bdsproj.local(470, 2012-05-09 18:10:06)
C:\Users\Michael\Documents\Borland Studio-Projekte\Project2.cfg(452, 2012-05-09 18:24:34)
C:\Users\Michael\Documents\Borland Studio-Projekte\Project2.dpr(188, 2012-05-09 18:10:06)
C:\Users\Michael\Documents\Borland Studio-Projekte\Project2.exe(640000, 2012-05-09 18:21:38)
C:\Users\Michael\Documents\Borland Studio-Projekte\Project2.identcache(153, 2012-05-09 18:24:34)
C:\Users\Michael\Documents\Borland Studio-Projekte\Project2.res(4396, 2012-05-09 17:43:34)
C:\Users\Michael\Documents\Borland Studio-Projekte\Unit2.dcu(6676, 2012-05-09 18:21:36)
C:\Users\Michael\Documents\Borland Studio-Projekte\Unit2.dfm(1404, 2012-05-09 18:10:00)
C:\Users\Michael\Documents\Borland Studio-Projekte\Unit2.pas(2060, 2012-05-09 18:21:34)
C:\Users\Michael\Documents\Meine empfangenen Dateien\2012-06-26-00 (Geschnitten).wmv(58629928, 2012-06-30 04:01:04)
C:\Users\Michael\Documents\My Games\Beyond the Sword\Logs\init.log(336, 2012-06-28 09:07:32)
C:\Users\Michael\Documents\My Games\Beyond the Sword\Logs\PythonErr2.log(7556, 2012-06-28 09:07:40)
C:\Users\Michael\Documents\My Games\Beyond the Sword\Logs\resmgr.log(0, 2012-06-28 09:07:32)
C:\Users\Michael\Documents\My Games\Beyond the Sword\Logs\xml.log(477, 2012-06-28 09:07:32)
C:\Users\Michael\Documents\My Games\Beyond the Sword\ScreenShots\FrozenScreen.tga(3686431, 2012-06-28 09:07:44)
C:\Users\Michael\Documents\My Games\Beyond the Sword\CivilizationIV.ini(5591, 2012-06-28 09:07:56)
C:\Users\Michael\Documents\My Games\Sid Meier's Civilization IV Colonization\Logs\init.log(322, 2012-06-28 09:14:16)
C:\Users\Michael\Documents\My Games\Sid Meier's Civilization IV Colonization\Logs\PythonErr2.log(5973, 2012-06-28 09:43:20)
C:\Users\Michael\Documents\My Games\Sid Meier's Civilization IV Colonization\Logs\resmgr.log(0, 2012-06-28 09:14:16)
C:\Users\Michael\Documents\My Games\Sid Meier's Civilization IV Colonization\Logs\xml.log(477, 2012-06-28 09:14:16)
C:\Users\Michael\Documents\My Games\Sid Meier's Civilization IV Colonization\Saves\single\auto\AutoSave_Initial_n. Chr.-1492.ColonizationSave(49372, 2012-06-28 09:16:06)
C:\Users\Michael\Documents\My Games\Sid Meier's Civilization IV Colonization\Saves\single\auto\AutoSave_n. Chr.-1564.ColonizationSave(85614, 2012-06-28 09:34:40)
C:\Users\Michael\Documents\My Games\Sid Meier's Civilization IV Colonization\Saves\single\auto\AutoSave_n. Chr.-1568.ColonizationSave(87469, 2012-06-28 09:36:50)
C:\Users\Michael\Documents\My Games\Sid Meier's Civilization IV Colonization\Saves\single\auto\AutoSave_n. Chr.-1572.ColonizationSave(87887, 2012-06-28 09:38:08)
C:\Users\Michael\Documents\My Games\Sid Meier's Civilization IV Colonization\Saves\single\auto\AutoSave_n. Chr.-1576.ColonizationSave(88959, 2012-06-28 09:39:52)
C:\Users\Michael\Documents\My Games\Sid Meier's Civilization IV Colonization\Saves\single\auto\AutoSave_n. Chr.-1580.ColonizationSave(90802, 2012-06-28 09:41:42)
C:\Users\Michael\Documents\My Games\Sid Meier's Civilization IV Colonization\Saves\single\Michael n. Chr.-1583.ColonizationSave(92585, 2012-06-28 09:43:08)
C:\Users\Michael\Documents\My Games\Sid Meier's Civilization IV Colonization\Saves\WorldBuilder\WBQuickSave.ColonizationWBSave(179790, 2012-06-28 09:16:06)
C:\Users\Michael\Documents\My Games\Sid Meier's Civilization IV Colonization\ScreenShots\FrozenScreen.tga(3686431, 2012-06-28 09:42:30)
C:\Users\Michael\Documents\My Games\Sid Meier's Civilization IV Colonization\CivilizationIV.ini(5497, 2012-06-28 09:17:10)
C:\Users\Michael\Documents\My Games\Warlords\Logs\init.log(311, 2012-06-28 07:03:06)
C:\Users\Michael\Documents\My Games\Warlords\Logs\PythonErr2.log(6283, 2012-06-28 07:03:16)
C:\Users\Michael\Documents\My Games\Warlords\Logs\resmgr.log(0, 2012-06-28 07:03:04)
C:\Users\Michael\Documents\My Games\Warlords\Logs\xml.log(471, 2012-06-28 07:03:06)
C:\Users\Michael\Documents\My Games\Warlords\Replays\Michael_n. Chr.-1330_0.CivWarlordsReplay(205617, 2012-06-28 09:04:54)
C:\Users\Michael\Documents\My Games\Warlords\Replays\Minimap.dds(131200, 2012-06-28 09:04:54)
C:\Users\Michael\Documents\My Games\Warlords\Saves\single\auto\AutoSave_Initial_v. Chr.-4000.CivWarlordsSave(66705, 2012-06-28 07:07:38)
C:\Users\Michael\Documents\My Games\Warlords\Saves\single\auto\AutoSave_n. Chr.-1160.CivWarlordsSave(196248, 2012-06-28 08:53:00)
C:\Users\Michael\Documents\My Games\Warlords\Saves\single\auto\AutoSave_n. Chr.-1200.CivWarlordsSave(200851, 2012-06-28 08:57:00)
C:\Users\Michael\Documents\My Games\Warlords\Saves\single\auto\AutoSave_n. Chr.-1240.CivWarlordsSave(205031, 2012-06-28 08:59:14)
C:\Users\Michael\Documents\My Games\Warlords\Saves\single\auto\AutoSave_n. Chr.-1280.CivWarlordsSave(210175, 2012-06-28 09:02:12)
C:\Users\Michael\Documents\My Games\Warlords\Saves\single\auto\AutoSave_n. Chr.-1320.CivWarlordsSave(213261, 2012-06-28 09:03:34)
C:\Users\Michael\Documents\My Games\Warlords\Saves\single\Michael n. Chr.-1330.CivWarlordsSave(214985, 2012-06-28 09:04:40)
C:\Users\Michael\Documents\My Games\Warlords\Saves\WorldBuilder\WBQuickSave.CivWarlordsWBSave(379053, 2012-06-28 07:07:38)
C:\Users\Michael\Documents\My Games\Warlords\CivilizationIV.ini(5780, 2012-06-28 09:05:54)
C:\Users\Michael\Documents\Scanned Documents\desktop.ini(81, 2012-03-13 14:53:20)
C:\Users\Michael\Documents\Default.rdp(0, 2012-03-16 22:23:44)
C:\Users\Michael\Documents\desktop.ini(402, 2012-07-11 13:31:18)
C:\Users\Michael\Documents\TXCUserDictionary.dic(620, 2012-05-01 20:20:50)
Das ist natürlich etwas unübersichtlich. Wie bekomme ich dass jetzt in eine Baumansicht als Text?

Code:
C:\Users
   Michael
      Documents
         Borland Studio-Projekte
            __history
               Unit1.dfm.~1~(606, 2012-04-20 22:35:10)
               Unit1.pas.~10~(2593, 2012-04-20 23:03:16)
         Meine empfangenen Dateien
            2012-06-26-00 (Geschnitten).wmv(58629928, 2012-06-30 04:01:04)
         My Games
            Beyond the Sword
               Logs
                  init.log(336, 2012-06-28 09:07:32)
Mir fehlt da irgendwie gerade die Idee.

Oder hatten wir so was schon mal un dich habe es nicht gefunden?

Das kann entweder sofort passieren oder man kann es auch nachher parsen und die Baumansicht nachträglich erzeugen. Das ist egal.
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
 


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 20:25 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz