I found that the above code was not really necessary as Text documents dont really come in Mega Bytes. So, using this snippet will get the Kilobyte of a document (or any file actually).
Code:function Get_File_Size1(sFileToExamine: string; bInKBytes: Boolean): string; var FileHandle: THandle; FileSize: LongWord; d1: Double; i1: Int64; begin FileHandle:= CreateFile(PChar(sFileToExamine), GENERIC_READ, 0, {exclusive} nil, {security} OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); FileSize:= GetFileSize(FileHandle, nil); Result:= IntToStr(FileSize); CloseHandle(FileHandle); if bInKbytes = True then begin if Length(Result) > 3 then begin Insert('.', Result, Length(Result) - 2); d1:= StrToFloat(Result); Result:= IntToStr(round(d1)) + 'KB'; end else Result:= '1KB'; end; end;





Reply With Quote