Warum doppelt abfragen?
Delphi-Quellcode:
class function TFileHelper.GetSize(const fileName: String): Int64;
var
info: TWin32FileAttributeData;
begin
if not GetFileAttributesEx(PChar(fileName), GetFileExInfoStandard, @info) then
RaiseLastOSError;
Result := Int64(info.nFileSizeLow) or Int64(info.nFileSizeHigh shl 32);
end;
Wenn es aber unbedingt EFileNotFoundException sein soll, dann halt
Delphi-Quellcode:
class function TFileHelper.GetSize(const fileName: String): Int64;
var
info: TWin32FileAttributeData;
begin
if not GetFileAttributesEx(PChar(fileName), GetFileExInfoStandard, @info) then
if GetLastError in [ERROR_FILE_NOT_FOUND, ERROR_PATH_NOT_FOUND] then
raise EFileNotFoundException.CreateRes(@SFileNotFound)
else
RaiseLastOSError;
Result := Int64(info.nFileSizeLow) or Int64(info.nFileSizeHigh shl 32);
end;