Re: Get Download Status; C++; IdFTPClient

Giganews Newsgroups
Subject: Re: Get Download Status; C++; IdFTPClient
Posted by:  Remy Lebeau (TeamB) (no.spam@no.spam.com)
Date: Wed, 7 Sep 2005

"Joe Pool" <jpo…@letourneau-inc.com> wrote in message
news:44AD1BAA56D9E240jpo…@letourneau-inc.com...

> How can I determine the progress of a download (i.e. to
> update a Progress Bar)?

Use the OnWork events.

>  TIdFTPListItem* Item = new TIdFTPListItem(NULL);
<snip>
>      Item = IdFtp1->DirectoryListing->Items[i++];

That is a memory leak.  You are allocating a new object that you never use.
The first time the loop executes, you are re-assigning the pointer value to
pointer to another object, thus losing the pointer to the memory you
allocated.

>        FileStream = new TFileStream("C:\setup.exe", fmCreate |
> fmShareDenyWrite);

You are missing a slash in the filename.  You must always escape forward
slashes in string/character literals:

    FileStream = new TFileStream("C:\\setup.exe", fmCreate |
fmShareDenyWrite);

>        i = IdFtp1->DirectoryListing->Count + 1;  // forces to exit the
loop

Use a 'break' statement instead to exit the loop.

Gambit

Replies

None

In response to

Get Download Status; C++; IdFTPClient posted by Joe Pool on Wed, 7 Sep 2005