1 (edited by gonpublic2k 2019-09-18 13:16:10)

Topic: How to display sum of file sizes when using OnDropFiles?

Hi, I'd like to display on a label the sum of the archives sizes as they are being dropped on a memo field, using the
OnDropFiles procedure of the memo component.  Please provide script if possible.

Thanks!

Re: How to display sum of file sizes when using OnDropFiles?

Hello.


procedure Form1_Memo1_OnDropFiles (Sender: TObject; ArrayOfFiles: array of string; X, Y: Integer);
var
    i, c: integer;
    Size: Int64;
begin
    Size := 0;
    c := Length(ArrayOfFiles)-1;
    for i := 0 to c do
    begin
        Size := Size + GetFileSize(ArrayOfFiles[i]);
        Form1.Memo1.Lines.Add(ArrayOfFiles[i]);
    end;
    Form1.Label1.Caption := IntToStr(Size);
end;
Dmitry.

Re: How to display sum of file sizes when using OnDropFiles?

DriveSoft wrote:

Hello.


procedure Form1_Memo1_OnDropFiles (Sender: TObject; ArrayOfFiles: array of string; X, Y: Integer);
var
    i, c: integer;
    Size: Int64;
begin
    Size := 0;
    c := Length(ArrayOfFiles)-1;
    for i := 0 to c do
    begin
        Size := Size + GetFileSize(ArrayOfFiles[i]);
        Form1.Memo1.Lines.Add(ArrayOfFiles[i]);
    end;
    Form1.Label1.Caption := IntToStr(Size);
end;

Excellent!  as always, thanks Dmitry!