unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, ExtCtrls, ComCtrls, StdCtrls;
type
TForm1 =
class(TForm)
MainMenu1: TMainMenu;
Memo1: TMemo;
Splitter1: TSplitter;
Datei: TMenuItem;
Aktualisieren1: TMenuItem;
ListBox1: TListBox;
procedure Aktualisieren1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
mompath:
string;
files:TStrings;
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure FindAllFiles(
var FileList: TStrings; RootFolder:
string; Mask:
string =
'
*.*'; 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
FindAllFiles(FileList, 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
FileList.Add(RootFolder + SR.
Name);
// hier tritt der Fehler auf
end;
until FindNext(SR) <> 0;
finally
FindClose(SR);
end;
end;
procedure TForm1.Aktualisieren1Click(Sender: TObject);
var i:integer;
begin
FindAllfiles(files,'
C:\Programme\Selfmade\Reader\TXT files','
*.txt',false);
for i:=0
to files.count -1
do
Listbox1.Items.addObject(extractFileName(files.Strings[i]),TObject(files.Strings[i]));
end;
end.