Reputation: 13
I need to get size of File. I need to check if file more then 100b example:
If FileSize('C:\Program Files\MyProgramm\MyApp.exe') > 100
then
msgbox ('File more then 100', mbinformation,mb_ok)
else
msgbox ('File less then 100', mbinformation,mb_ok)
I look function FileSize(const Name: String; var Size: Integer): Boolean; , but it's work only if I need check - size correct or not. But I cann't check on more or less
Upvotes: 1
Views: 1364
Reputation: 76693
The var
keyword in the function prototype means that you need to declare a variable of the given type and pass it to the function. That variable then receives the value. Here is an example with the FileSize
function:
var
Size: Integer;
begin
// the second parameter of the FileSize function is defined as 'var Size: Integer',
// so we need to pass there a variable of type Integer, which is the Size variable
// declared above
if FileSize('C:\TheFile.any', Size) then
begin
if Size > 100 then
MsgBox('The file is bigger than 100B in size.', mbInformation, MB_OK)
else
MsgBox('The file is smaller than 100B in size.', mbInformation, MB_OK);
end
else
MsgBox('Reading the file size failed.', mbError, MB_OK);
end;
Upvotes: 2