Autor Beitrag
Jagg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 635



BeitragVerfasst: Do 14.11.02 15:21 
Hallo,Leutz !

Kann man beim Aufruf einer Textdatei ihre Grösse bestimmen ? oder gibt es immer eine Standardgrösse beim Aufruf !

Jagg !
Ex0rzist
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 550

Win XP Prof.
Mandrake 10.0

D6
BeitragVerfasst: Do 14.11.02 17:26 
Hallo,

nimm doch einfach beim Aufrufen:SizeOf(File);

_________________
If accidentally read, induce vomitting.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 14.11.02 21:52 
Aus der Delphi-Hilfe:
Zitat:

Returns the number of bytes occupied by a variable or type.

Klingt nicht sehr erfolgsversprechend. :roll:

Entweder so:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
function MyGetFileSize(const Filename: string): TULargeInteger;
var
  Find: THandle;
  Data: TWin32FindData;
begin
  Result.QuadPart := -1;
  Find := FindFirstFile(PChar(Filename), Data);
  if (Find <> INVALID_HANDLE_VALUE) then
  begin
    Result.LowPart := Data.nFileSizeLow;
    Result.HighPart := Data.nFileSizeHigh;
    Windows.FindClose(Find);
  end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
  if (OpenDialog1.Execute) then
    ShowMessage(IntToStr( MyGetFileSize(OpenDialog1.FileName).QuadPart ));
end;

Oder so:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
Function MyFileSize(Filename:string):integer;
var SR : TSearchRec;
begin
  if FindFirst(Filename,faAnyFile,SR)=0 then
    Result:=SR.Size
  else
    Result:=-1;
  FindClose(SR);
end;