Как проверить, пуста директория, или нет?
function DirectoryIsEmpty( Directory: string ): boolean;
var
sr: TSearchRec;
i: Integer;
begin
Result := false;
FindFirst( IncludeTrailingPathDelimiter( Directory ) + '*', faAnyFile, sr );
for i := 1 to 2 do
if ( sr.Name = '.' ) or ( sr.Name = '..' ) then
Result := FindNext( sr ) <> 0;
FindClose( sr );
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if DirectoryIsEmpty( 'C:\test' ) then
Caption := 'Пустая директория'
else
Caption := 'В директории есть файлы';
end; |