我有这个例程来查看文件大小:
(基于http://delphi.about.com/od/delphitips2008/qt/filesize.htm)
function FileSize(fileName : String) : Int64;
var
sr : TSearchRec;
begin
if FindFirst(fileName, faAnyFile, sr ) = 0 then
{$IFDEF MSWINDOWS}
result := Int64(sr.FindData.nFileSizeHigh) shl Int64(32) + Int64(sr.FindData.nFileSizeLow)
{$ELSE}
result := sr.Size
{$ENDIF}
else
result := -1;
FindClose(sr) ;
end;
然而,这会出现以下警告:
[DCC Warning] Funciones.pas(61): W1002 Symbol 'FindData' is specific to a platform
我想知道是否存在一种干净的跨平台方法来做到这一点。我检查了TFile类,但没有找到它...