I am Experimenting with get a file from our webside server via Ftp. I have 2 Machines 1 a laptop runing XP Delphi 6 Indy 10.5.8.0 An a machine runing Window 7 Delphi XE2 with Indy 10.5.8.0. I am using the Same Code on Both. procedure TFrmMain.ProcessItemDalySpecial; var PathDest : String; FileName : String; begin with FrmTb2 do begin if ReadIniBoolean(IniCfg,'FTP','UseFtpDaly') then begin Ftp.Host := ReadIniStr(IniCfg,'FTP','HostDaly'); Ftp.Port := ReadIniInt(IniCfg,'FTP','Port'); Ftp.UserName := ReadIniStr(IniCfg,'FTP','UserIdDaly'); Ftp.Password := ReadIniStr(IniCfg,'FTP','PasswordDaly'); PathDest := 'C:'; FileName := 'monthly_special.txt'; PathDest := PathDest + '\' + FileName; Ftp.TransferType := ftASCII; Ftp.Connect; ftp.Get(FileName,PathDest,True); Ftp.Disconnect; end; end; end; procedure TFrmMain.FTPWork(ASender: TObject; AWorkMode: TWorkMode; AWorkCount: Int64); begin // FldProgressCurrent.Percent := round(100 *(AWorkCount / TotalFtp)); end; procedure TFrmMain.FTPWorkBegin(ASender: TObject; AWorkMode: TWorkMode; AWorkCountMax: Int64); begin FldProgressCurrent.Percent := 0; WorkCount := 0; TotalFtp := AWorkCountMax; end; The Machine runing Delphi 6 Errors on the Get with a connection closed Gracefully and the XE machine works fine Also AWorkCountMax was not to be 0 but the size of the file being transferd causing me to get a divison by zero error on both machines Thanks Donald S. Bossen
![]() |
0 |
![]() |
Donald wrote: > The Machine runing Delphi 6 Errors on the Get with a connection closed > Gracefully That means the server is closing the connection. Which line of code are you seeing this happen on exactly? Are you seeing the exception occur only while running in the debugger, or do you see it when running outside of the debugger? Also keep in mind that FTP uses 2 connections, on for commands and one for transfers, so you might just be seeing the exception occur on the data connection after the server is finished transferring the file. That exception should not be reaching your code, since TIdFTP handles it internally. > Also AWorkCountMax was not to be 0 but the size of the file being > transferd causing me to get a divison by zero error on both machines AWorkCountMax will always be 0 when downloading a file via FTP. This is because the FTP protocol does not provide the total file size during a download. You will have to use TIdFTP.List() or TIdFTP.Size() to discover the file size prior to calling TIdFTP.Get(). This is not a problem with TIdFTP.Put(), and TIdFTP knows the size of the file it is uploading. -- Remy Lebeau (TeamB)
![]() |
0 |
![]() |
> {quote:title=Remy Lebeau (TeamB) wrote:}{quote} > Donald wrote: > > > The Machine runing Delphi 6 Errors on the Get with a connection closed > > Gracefully > > That means the server is closing the connection. Which line of code are > you seeing this happen on exactly? Are you seeing the exception occur only > while running in the debugger, or do you see it when running outside of the > debugger? Also keep in mind that FTP uses 2 connections, on for commands > and one for transfers, so you might just be seeing the exception occur on > the data connection after the server is finished transferring the file. > That exception should not be reaching your code, since TIdFTP handles it > internally. > > > Also AWorkCountMax was not to be 0 but the size of the file being > > transferd causing me to get a divison by zero error on both machines > > AWorkCountMax will always be 0 when downloading a file via FTP. This is > because the FTP protocol does not provide the total file size during a download. > You will have to use TIdFTP.List() or TIdFTP.Size() to discover the file > size prior to calling TIdFTP.Get(). This is not a problem with TIdFTP.Put(), > and TIdFTP knows the size of the file it is uploading. > > -- > Remy Lebeau (TeamB) Thank You I worked when I ran it Stand alone and when I used size I was able to fix the div by zero problem Donald S. Bossen
![]() |
0 |
![]() |