Autor Beitrag
TheUnknown
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 334



BeitragVerfasst: Mo 24.06.02 09:41 
...


Zuletzt bearbeitet von TheUnknown am Do 22.08.13 09:14, insgesamt 1-mal bearbeitet
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Mo 24.06.02 10:29 
Hallo,

mit function FileSize(var F): Integer; bekommst du die Anzahl der Blöcke einer Datei wierder. Wenn du f als FILE OF Byte deklarierst entspricht das der Anzahl in Byte.

Alternativ kannst du noch über FindFirst gehen.

Gruß
Klabautermann
TheUnknown Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 334



BeitragVerfasst: Mo 24.06.02 11:11 
...


Zuletzt bearbeitet von TheUnknown am Do 22.08.13 09:15, insgesamt 1-mal bearbeitet
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Mo 24.06.02 11:32 
Titel: Re: JAU, GEHT!!!! SUUUUUUUUUUUUPER!
TheUnknown hat folgendes geschrieben:
So geht's - und Danke Klabautermann...

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
function DateiGroesse : String;
var SR : TSearchRec;
    FileAttrs : Integer;
begin
  if FindFirst('C:\AUTOEXEC.BAT', FileAttrs, sr) = 0
  then Result := FormatFloat('#,#0', SR.Size);
end;


Freut mich das es klappt aber du machst ein Speicherleck.
Erweitere deine Funktion folgendermaßen:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
function DateiGroesse : String;
var SR : TSearchRec;
    FileAttrs : Integer;
begin
  if FindFirst('C:\AUTOEXEC.BAT', FileAttrs, sr) = 0 then begin
    Result := FormatFloat('#,#0', SR.Size);
    FindClose(sr); // Wichtig
  end;
end;


FindClose gibt den mit FindFirst zugewiesenen Speicher frei.

Gruß
Klabautermann
Pit
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 160



BeitragVerfasst: Mo 24.06.02 12:03 
Titel: Re: JAU, GEHT!!!! SUUUUUUUUUUUUPER!
Dieses Thema ist gesperrt, Du kannst keine Beiträge editieren oder beantworten.

Das Thema wurde von einem Team-Mitglied geschlossen. Wenn du mit der Schließung des Themas nicht einverstanden bist, kontaktiere bitte das Team.