如何编程得到任意一个文件的大小---求助(10分)

  • 主题发起人 主题发起人 quietosea
  • 开始时间 开始时间
Q

quietosea

Unregistered / Unconfirmed
GUEST, unregistred user!
如题:注意,不是该文件所占空间的大小,而是内部数据的大小(因为当打开文件的属性框时,上面会显示两个大小).
 
sysutil.pas 中有个函数,叫什么了,可能包含 size ,现没有delphi,<br>你搜一下。<br>
 
var<br>&nbsp; &nbsp;f: file of Byte;<br>&nbsp; &nbsp;size: Longint;<br>begin<br>&nbsp; &nbsp;AssignFile(f, '文件名');<br>&nbsp; &nbsp;Reset(f);<br>&nbsp; &nbsp;try<br>&nbsp; &nbsp; &nbsp;size := FileSize(f);<br>&nbsp; &nbsp;finally<br>&nbsp; &nbsp; &nbsp;CloseFile(f);<br>&nbsp; &nbsp;end;<br>end;
 
function FileSize(FileName: string):Integer;<br>var<br>&nbsp; TH: THandle;<br>&nbsp; TF: TWin32FindData;<br>begin<br>&nbsp; &nbsp;TH:= FindFirstFile(PChar(FileName), TF);<br>&nbsp; &nbsp;if TH &lt;&gt; INVALID_HANDLE_VALUE then<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp;Windows.FindClose(TH);<br>&nbsp; &nbsp; &nbsp;Result:= TF.nFileSizeLow;<br>&nbsp; &nbsp;end else Result:= 0;<br>end;<br>
 
后退
顶部