Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Oct : Re: Indy 10 FTP repost - getting urgent
| Subject: | Re: Indy 10 FTP repost - getting urgent |
| Posted by: | "Lee Cook" (lee.co..@kwikhols.co.uk) |
| Date: | Fri, 20 Oct 2006 11:43:21 |
Gambit
Yes here is my code:-
Procedure DownloadThread.DownloadPureFlights;
Var
cOkFile,cSavePath,cFileName: String;
dServerDate,dLocalDate: TDateTime;
lDownload: Boolean;
mDownload: TMemoryStream;
aOkFile: TStringList;
Begin
Priority := tpHighest;
cSavePath := MainIni.ReadString('Paths','Downloads','')+'Pure\';
ForceDirectories(cSavePath);
aOkFile := TStringList.Create;
If ControlForm.IdFTP1.Connected = True Then
ControlForm.IdFTP1.Disconnect;
ControlForm.IdFTP1.Host := 'xx.xxx.xxx.xx';
ControlForm.IdFTP1.Username := 'xxxxx';
ControlForm.IdFTP1.Password := 'xxxxx';
ControlForm.IdFTP1.ConnectTimeout := 10000;
ControlForm.IdFTP1.TransferTimeout := 60000;
ControlForm.IdFTP1.OnWork := Nil;
ControlForm.IdFTP1.OnWorkBegin := Nil;
Try
ControlForm.IdFTP1.Connect;
cFileName := 'Custom.zip';
cOkFile :=
StringReplace(cFileName,'.Zip','.Ok',[rfreplaceall,rfignorecase]);
MainForm1.FTPfilename.Caption := cFileName;
Try
dServerDate := ControlForm.IdFTP1.FileDate(cFileName,True);
Except
dServerDate := Now;
End;
If FileExists(cSavePath+cFileName) Then Begin
dLocalDate := FileDateToDateTime(FileAge(cSavePath+cFileName));
If dServerDate > dLocalDate Then lDownload := True Else lDownload :=
False;
End Else Begin
dServerDate := ControlForm.IdFTP1.FileDate(cFileName,True);
lDownload := True;
End;
If lDownload = True Then Begin
MainForm1.FTPfilename.Caption := cFileName;
MainForm1.FTPfilesize.Caption :=
IntToStr(ControlForm.IdFTP1.Size(cFileName));
MainForm1.FTPprogress.MaxValue :=
StrToInt(MainForm1.FTPfilesize.Caption);
ControlForm.IdFTP1.OnWork := ControlForm.IdFTP1Work;
ControlForm.IdFTP1.OnWorkBegin := ControlForm.IdFTP1WorkBegin;
MainForm1.FTPstatus.Caption := 'Transfer In Progress';
Try
mDownload := TMemoryStream.Create;
ControlForm.IdFTP1.Get(cFileName,mDownload,False);
mDownload.SaveToFile(cSavePath+cFileName);
FileSetDate(cSavePath+cFileName,
DateTimeToFileDate(IncMinute(dServerDate,1)));
mDownload.Free;
aOkFile.SaveToFile(cSavePath+cOkFile);
Except
End;
End;
ControlForm.IdFTP1.Disconnect;
Except
End;
aOkFile.Free;
End;
I use the same code for many different FTP downloads for many different
servers its just this one server that is causing me the problem.
Cheers
Lee
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:4538a403$1@newsgroups.borland.com...
>
> "Lee Cook" <lee.cook@kwikhols.co.uk> wrote in message
> news:45387fa1$1@newsgroups.borland.com...
>
>> If i run the application outside of the debugger it just hangs at
>> the connect with no errors or anything
>
> Did you set the ConnectTimeout and ReadTimeout properties?
>
>
> Gambit