在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
Delphi 获得文件大小的方法 大概有这些:
if OpenDialog1.Execute then
begin
ShowMessage(IntToStr(FileSizeByName(OpenDialog1.Filename)));
end;
2、GetFileSize var FileHandle:integer; begin if OpenDialog1.Execute then begin FileHandle := FileOpen(OpenDialog1.FileName, 0); ShowMessage(IntToStr(GetFileSize(FileHandle, nil))); FileClose(FileHandle); end;
3、FileSize(不能获得正在使用的文件大小) var f: file;
begin
if OpenDialog1.Execute then
begin
AssignFile(f, OpenDialog1.FileName);
Reset(f, 1);
ShowMessage(IntToStr(FileSize(f)));
CloseFile(f);
end;
end;
var
FileHandle:integer;
begin
if OpenDialog1.Execute then
begin
FileHandle := FileOpen(OpenDialog1.FileName, 0);
ShowMessage(IntToStr(FileSeek(FileHandle,0,2)));
FileClose(FileHandle);
end;
end;
var
FS: TFileStream;
begin
if OpenDialog1.Execute then begin
FS := TFileStream.Create(OpenDialog1.FileName, fmShareDenyNone);
ShowMessage(IntToStr(FS.Size));
FS.Free;
end;
end;
另在IdGlobalProtocols中有个FileSizeByName()的函数。
创建时间:2015-05-01 更新时间:2020.01.02 来源于:https://www.cnblogs.com/guorongtao/p/4470185.html
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论