Ĺadny brzuch
W faq wskazówka nr 65 opisuje jak wyszukać jakiś plik na dysku, np mama.txt, i o ile sam kod jest napisany bardzo dobrze, to nie wyszukuje on dowolnych plików np *.txt. Jak można to poprawić?
procedure findfiles(path:string); var f:integer; sr:tsearchrec; begin if (path[length(path)]<>'\') then path:=path+'\'; f:=findfirst(path+'*.txt',faAnyFile,sr); while (f=0) do begin if (sr.name[1]<>'.') then ShowMessage(path+sr.Name); f:=findnext(sr); end; findclose(sr); // katalogi f:=findfirst(path+'*.*',faDirectory,sr); while (f=0) do begin if (sr.name[1]<>'.') then findfiles(path+sr.Name); f:=findnext(sr); end; findclose(sr); end;
Wyszuka pliki .txt.
Wywołanie:
findfiles('d:\');
Użytkownik krajew4 edytował ten post 04 lipiec 2006, 07:16
zanotowane.pl doc.pisz.pl pdf.pisz.pl zsf.htw.pl
procedure findfiles(path:string); var f:integer; sr:tsearchrec; begin if (path[length(path)]<>'\') then path:=path+'\'; f:=findfirst(path+'*.txt',faAnyFile,sr); while (f=0) do begin if (sr.name[1]<>'.') then ShowMessage(path+sr.Name); f:=findnext(sr); end; findclose(sr); // katalogi f:=findfirst(path+'*.*',faDirectory,sr); while (f=0) do begin if (sr.name[1]<>'.') then findfiles(path+sr.Name); f:=findnext(sr); end; findclose(sr); end;
Wyszuka pliki .txt.
Wywołanie:
findfiles('d:\');
Użytkownik krajew4 edytował ten post 04 lipiec 2006, 07:16