Ĺadny brzuch
Mam oto właśnie taki kod. Działa z dyskami ale z c:\Windows nie radzi sobie, tylko nie wiem czemu?
var PathText:String; Found:Integer; SR : TSearchRec; begin PathText := 'C:\Windows'; Found := FindFirst(PathText + '*.*', faAnyFile, SR); while (Found = 0) do begin if (SR.name <> '.') and (SR.name <> '..') then begin if Pos('.', PathText + SR.name) > 0 then begin if (SR.Size < 1024) then begin ListBox1.Items.Add(PathText + SR.name + ' plik ' + IntToStr(SR.Size) + 'b'); end else if(SR.Size >= 1024) and (SR.Size < 1048576) then begin SR.Size := SR.Size div 1024; ListBox1.Items.Add(PathText + SR.name + ' plik ' + IntToStr(SR.Size) + 'KB'); end else if(SR.Size >= 1048576) then begin SR.Size := SR.Size div 1048576; ListBox1.Items.Add(PathText + SR.name + ' plik ' + IntToStr(SR.Size) + 'MB'); end; Found := FindNext(SR); end else begin ListBox1.Items.Add(PathText + SR.name + ' folder'); Found := FindNext(SR); // reszta nawiasów
Z góry dziękuje.
Użytkownik Maksiu edytował ten post 23 listopad 2005, 08:16
Musisz ścieżkę podawać ze shashem np.
PathString:='C:\Windows\';
Yo. Dobra super tylko i tak nie chodzi :P
A co nie działa, nie wypisuje się czy co? :huh:
procedure Find(s:string); var sr:TSearchRec; f:integer; begin if s[length(s)]<>'\' then s:=s+'\'; f:=findFirst(s+'*.*',faAnyFile,sr); while f=0 do begin ShowMessage(s+sr.name); f:=findnext(sr); end; findclose(sr); end;
Użytkownik krajew4 edytował ten post 23 listopad 2005, 08:39
procedure Tform1.Button1Click; var PathText:String; Found:Integer; SR : TSearchRec; begin PathText := 'C:\Windows'; Found := FindFirst(PathText + '\*.*', faAnyFile, SR); while Found = 0 do begin if (SR.name <> '.') and (SR.name <> '..') then begin if Pos('.', PathText + SR.name) > 0 then begin if (SR.Size < 1024) then begin ListBox1.Items.Add(PathText +'\'+ SR.name + ' plik ' + IntToStr(SR.Size) + 'b'); end else if(SR.Size >= 1024) and (SR.Size < 1048576) then begin SR.Size := SR.Size div 1024; ListBox1.Items.Add(PathText +'\'+ SR.name + ' plik ' + IntToStr(SR.Size) + 'KB'); end else if(SR.Size >= 1048576) then begin SR.Size := SR.Size div 1048576; ListBox1.Items.Add(PathText +'\'+ SR.name + ' plik ' + IntToStr(SR.Size) + 'MB'); end; end else begin ListBox1.Items.Add(PathText +'\'+ SR.name + ' folder'); end; end; Found := FindNext(SR); end;błędy: brak "Found := FindNext(SR);" w razie wystąpienia "." lub ".." i "\" przy wypisywaniu :)
zanotowane.pl doc.pisz.pl pdf.pisz.pl zsf.htw.pl
var PathText:String; Found:Integer; SR : TSearchRec; begin PathText := 'C:\Windows'; Found := FindFirst(PathText + '*.*', faAnyFile, SR); while (Found = 0) do begin if (SR.name <> '.') and (SR.name <> '..') then begin if Pos('.', PathText + SR.name) > 0 then begin if (SR.Size < 1024) then begin ListBox1.Items.Add(PathText + SR.name + ' plik ' + IntToStr(SR.Size) + 'b'); end else if(SR.Size >= 1024) and (SR.Size < 1048576) then begin SR.Size := SR.Size div 1024; ListBox1.Items.Add(PathText + SR.name + ' plik ' + IntToStr(SR.Size) + 'KB'); end else if(SR.Size >= 1048576) then begin SR.Size := SR.Size div 1048576; ListBox1.Items.Add(PathText + SR.name + ' plik ' + IntToStr(SR.Size) + 'MB'); end; Found := FindNext(SR); end else begin ListBox1.Items.Add(PathText + SR.name + ' folder'); Found := FindNext(SR); // reszta nawiasów
Z góry dziękuje.
Użytkownik Maksiu edytował ten post 23 listopad 2005, 08:16
Musisz ścieżkę podawać ze shashem np.
PathString:='C:\Windows\';
Yo. Dobra super tylko i tak nie chodzi :P
A co nie działa, nie wypisuje się czy co? :huh:
procedure Find(s:string); var sr:TSearchRec; f:integer; begin if s[length(s)]<>'\' then s:=s+'\'; f:=findFirst(s+'*.*',faAnyFile,sr); while f=0 do begin ShowMessage(s+sr.name); f:=findnext(sr); end; findclose(sr); end;
Użytkownik krajew4 edytował ten post 23 listopad 2005, 08:39
procedure Tform1.Button1Click; var PathText:String; Found:Integer; SR : TSearchRec; begin PathText := 'C:\Windows'; Found := FindFirst(PathText + '\*.*', faAnyFile, SR); while Found = 0 do begin if (SR.name <> '.') and (SR.name <> '..') then begin if Pos('.', PathText + SR.name) > 0 then begin if (SR.Size < 1024) then begin ListBox1.Items.Add(PathText +'\'+ SR.name + ' plik ' + IntToStr(SR.Size) + 'b'); end else if(SR.Size >= 1024) and (SR.Size < 1048576) then begin SR.Size := SR.Size div 1024; ListBox1.Items.Add(PathText +'\'+ SR.name + ' plik ' + IntToStr(SR.Size) + 'KB'); end else if(SR.Size >= 1048576) then begin SR.Size := SR.Size div 1048576; ListBox1.Items.Add(PathText +'\'+ SR.name + ' plik ' + IntToStr(SR.Size) + 'MB'); end; end else begin ListBox1.Items.Add(PathText +'\'+ SR.name + ' folder'); end; end; Found := FindNext(SR); end;błędy: brak "Found := FindNext(SR);" w razie wystąpienia "." lub ".." i "\" przy wypisywaniu :)