Topic: GetFileSize Function
Hello Dmitry,
Is there anyway to use the GetFileSize function to display the size in MB of the files you attach to an e-mail? I want to display on a label, the
size in MB of files being attached so that when it reaches the maximum of attachments size (in this case 15MB ) the label displays the size in
RED. Otherwise, if it's less than 15MB displays it in GREEN.
Here's a sample code I copied for the attachments: (Note: This code is not working, I'm not sure how to use the GetFileSize function for
my purposes here .. )
procedure Form1_attached_OnClick (Sender: TObject; var Cancel: boolean);
var
OpenDialog: TOpenDialog;
d: int64;
i: integer;
begin
OpenDialog := TOpenDialog.Create(Form1);
try
if OpenDialog.Execute then
begin
if FileExists(OpenDialog.FileName) then Form1.mmfiles.Lines.Add(OpenDialog.FileName);
d := GetFileSize(OpenDialog.FileName);
i := d;
Form1.MBSize.Caption := FormatFloat('0.00', i/(1024*1024)); //MB
end;
finally
OpenDialog.Free;
end;
end;
Thanks , appreciate your help!