1. uses filectrl, 用 ForceDirectories 函数。
2.
var
Status: Integer;
SearchRec: TSearchRec;
i: Integer;
begin
i := 0;
Status := FindFirst(DirName+'/*.BMP', faAnyFile, SearchRec);
try
while Status = 0 do
begin
inc(i);
Status := FindNext(SearchRec);
end;
finally
FindClose(SearchRec);
end;
result := i;