How to get the size of a file #50
Here is a function to get the size of a file by using the native Pascal I/O and file management routines. The function returns -1 if the file doesn't exist.
function GetFileSize(FName: string): Int64; var ch: File; OldMode: Integer; begin OldMode := FileMode; Result := -1; if not FileExists(FName) then Exit; try AssignFile(ch, FName); FileMode := 0; Reset(ch,1); Result := FileSize(ch); finally CloseFile(ch); FileMode := OldMode; end; end;
Author: | Joe Donth |
---|---|
Contributor: | Joe Donth |
Added: | 2007/08/14 |
Last updated: | 2007/08/14 |