Wah kalian neeeh yang biasanya mau bikin aplikasi multimedia atau utilities, salah satu syaratnya harus mampu membaca jumlah isi dari suatu direktori kan?? nah ini adalah kode buat kalian yang ingin melakukan hal iut heehehe check itdot !!! >
function GetFilesCount(Folder, WildCard: string): Integer;
var
intFound: Integer;
SearchRec: TSearchRec;
begin
Result := 0;
if (Folder <> '') and (Folder[Length(Folder)] <> '\') then
Folder := Folder + '\';
intFound := FindFirst(Folder + WildCard, faAnyFile, SearchRec);
while (intFound = 0) do
begin
if not (SearchRec.Attr and faDirectory = faDirectory) then
Inc(Result);
intFound := FindNext(SearchRec);
end;
FindClose(SearchRec);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
//Edit1.Text := IntToStr(GetFilesCount('c:\windows\', '*.bmp'));
Edit1.Text := IntToStr(GetFilesCount('c:\My Documents', '*.*'));
end;
var
intFound: Integer;
SearchRec: TSearchRec;
begin
Result := 0;
if (Folder <> '') and (Folder[Length(Folder)] <> '\') then
Folder := Folder + '\';
intFound := FindFirst(Folder + WildCard, faAnyFile, SearchRec);
while (intFound = 0) do
begin
if not (SearchRec.Attr and faDirectory = faDirectory) then
Inc(Result);
intFound := FindNext(SearchRec);
end;
FindClose(SearchRec);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
//Edit1.Text := IntToStr(GetFilesCount('c:\windows\', '*.bmp'));
Edit1.Text := IntToStr(GetFilesCount('c:\My Documents', '*.*'));
end;

Tidak ada komentar:
Posting Komentar