我需要文件的大小。我需要检查文件是否超过100 b示例:
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)我看起来像函数FileSize(const名称: String;var大小:整数):布尔;,但这是工作,只有当我需要检查大小正确与否.但我不能多多少少检查
发布于 2015-08-05 10:15:55
函数原型中的var关键字意味着需要声明给定类型的变量并将其传递给函数。然后,该变量接收该值。下面是FileSize函数的一个示例:
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;https://stackoverflow.com/questions/31829275
复制相似问题