Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Mar : Re: IdFTP.Get Not Firing OnAfterGet
| Subject: | Re: IdFTP.Get Not Firing OnAfterGet |
| Posted by: | "Richard Stephens" (ri..@almsysinc.com) |
| Date: | Wed, 14 Mar 2007 12:06:21 |
>> I am using the syntax: IdFTP1.Get(WebFileName,LocalFileName,True);
>>
>> It DOES download the file and give it the correct LocalFileName,
>> but the IdFTP1.OnAfterGet logic does not fire.
>
> Yes, it does. That is a guarantee. Get(String, String, Boolean,
> Boolean) calls Get(String, Stream, Boolean) internally. That second
> Get() is what does all of the work, and always triggers the OnAfterGet
> event handler if successful. It is not possible for the OnAfterGet
> handler to be ignored on a successful transfer if it is assigned.
It does not fire it. I placed a ShowMessage statement in the OnAfterGet
routine. It never showed and the file downloaded fine. I am using the Indy
10 version that shipped with Delphi 2006 Enterprise. Perhaps there is
another Indy update that I should be applying? How does one tell what
version of Indy 10 one has?
>> I am using OnAfterGet to tell me that it was successful
>
> Indy is not an event-driven library. If Get() does not raise an
> exception, then the transfer was successful. You don't need an event
> to tell you that.
>
>> Rather, it simply returns control to the next statement after
>> the Get command. It does not get an exception.
Ok. Thanks for that information. I will just simply not use the OnAfterGet.
> IdFTP1.Get(WebFileName,LocalFileName,True,True);
>> and test it, it gives me an EIdFTPFileAlreadyExists exception ....
> but the
>> LocalFileName does not exist.
>
> Yes, it does. That exception is only raised if FileExists() returned
> True.
Any time that I send FALSE as AResume to the IdFTP.Get routine, it sends an
EIdFTPFileAlreadyExists exception with the message "Destination file already
exists". Well, the file does not exist, plain and simple. In fact, the
folder to which I am saving is empty. If I change it to always send TRUE, it
works.
Now, if the file does indeed exist in the target folder, then AResume=False
does not give the exception.
So, I will just make sure to always use TRUE.
Thanks for your help. It is very much appreciated.
Richard Stephens