Текущий архив: 2003.05.22;
Скачать: CL | DM;
Вниз
Как получить размер файла в байтах? Найти похожие ветки
← →
Lamerr (2003-05-09 10:56) [0]Собственно, сабж.
Нашел GetFileSize, но туда надо передавать дескриптор, который надо еще получить...
Нет ли способа попроще?
← →
Lamerr (2003-05-09 11:33) [1]Кажется, выкрутился...
Вопрос снимается.
← →
german goering (2003-05-09 11:41) [2]Два способа:
procedure TForm1.Button1Click(Sender: TObject);
var hFile: Cardinal;
Size: Cardinal;
begin
with TOpenDialog.Create(Self) do
try
if Execute then
begin
hFile := FileOpen(FileName,fmOpenRead);
try
Size := GetFileSize(hFile,nil);
ShowMessage("Filesize of """ + FileName + """ is " + IntToStr(Size) + " bytes");
finally
FileClose(hFile);
end;
end;
finally
Free;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var SearchRec: TSearchRec;
begin
with TOpenDialog.Create(Self) do
try
if Execute then
try
if FindFirst(FileName,faAnyFile,SearchRec) = 0
then
ShowMessage("Filesize of """ + FileName + """ is " + IntToStr(SearchRec.Size) + " bytes");
finally
FindClose(SearchRec);
end;
finally
Free;
end;
end;
?
← →
Lamerr (2003-05-09 11:50) [3]Спасибо, буду иметь в виду.
Страницы: 1 вся ветка
Текущий архив: 2003.05.22;
Скачать: CL | DM;
Память: 0.44 MB
Время: 0.006 c