Autor Beitrag
Bronstein
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 578
Erhaltene Danke: 1

WIN XP
Delphi 6 / Delphi 2006 / Delphi XE
BeitragVerfasst: Do 02.03.06 15:21 
Habe hier eine Funktion die mir alle Elemente eines Ordners auflistet (Dateien und Ordner). Jetzt möchte ich aber nur die Dateien und nicht auch noch die Ordner. Hier mal die Funktion:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure FindFiles (aPath, aFindMask: String; aWithSub: Boolean; aResult: tStrings);
Var
  FindRec: tSearchRec;
Begin
If FindFirst (aPath + aFindMask, faAnyFile, FindRec) = 0 Then
    Repeat
      If (FindRec.Name <> '.') and (FindRec.Name <> '..') Then
        // ...Ergebnis in die Stringlist einfügen
        aResult.Add (aPath + FindRec.Name);
    Until FindNext (FindRec) <> 0;
  FindClose (FindRec);
end;


Aufrufen tut man sie so z.B.:
FindFiles ('Pfad','*.*', True, ListBox1.Items);

Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt

_________________
Es gibt keine dummen Fragen nur dumme Antworten!!!
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 02.03.06 15:26 
Moin!

Stell mal den Cursor auf das markierte Wort und drück F1, dann noch das Gehirn einschalten... :wink:
ausblenden Delphi-Quelltext
1:
If FindFirst (aPath + aFindMask, faAnyFile, FindRec) = 0 Then					

cu
Narses

PS: Bitte benutze für Delphi-Code auch die Delphi-Tags! Danke.

_________________
There are 10 types of people - those who understand binary and those who don´t.
Bronstein Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 578
Erhaltene Danke: 1

WIN XP
Delphi 6 / Delphi 2006 / Delphi XE
BeitragVerfasst: Do 02.03.06 15:34 
Danke, kenn mich aber nicht so aus mit den Delphi Tags, programmiere hauptsächlich C++. Was ist da falsch?

_________________
Es gibt keine dummen Fragen nur dumme Antworten!!!
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 02.03.06 15:39 
Moin!

user profile iconBronstein hat folgendes geschrieben:
Danke, kenn mich aber nicht so aus mit den Delphi Tags, programmiere hauptsächlich C++. Was ist da falsch?

:wink: Das hat nix mit dem Code zu tun, sondern mit der Darstellung hier im Forum! :D Markier den Code und klick auf das Plus nebem der ComboBox "Delphi" im Editor, dann wird dein Code bei der Anzeige auch als Delphi-Code formatiert.

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Alpha_Wolf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 297

Ubuntu, Win XP, Win Vista
C#, Delphi 6 Prof, Delphi 2007 Prof, Java
BeitragVerfasst: Do 02.03.06 15:44 
Falls dir das alles nichts hilft.. die Suche hätte es sicherlich getan.

www.delphi-library.d...f12e37e2bd1&t=94

_________________
Diskutiere nie mit einem Irren - er zieht dich auf sein Niveau und schlägt dich mit seiner Erfahrung.