Error on Delphi 6 but not on Delphi Xe for Ftp

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
5/31/2013 8:28:12 PM
embarcadero.delphi.winsock 1874 articles. 2 followers. Follow

2 Replies
1327 Views

Similar Articles

[PageSpeed] 20

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
Remy
5/31/2013 9:14:30 PM
> {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
Donald
5/31/2013 9:36:13 PM
Reply:

Web resources about - Error on Delphi 6 but not on Delphi Xe for Ftp - embarcadero.delphi.winsock

Delphi - Wikipedia, the free encyclopedia
... an archaeological site and a modern town in Greece on the south-western spur of Mount Parnassus in the valley of Phocis . The site of Delphi ...

Delphi Automotive (@DelphiAuto) on Twitter
Log in Sign up You are on Twitter Mobile because you are using an old version of Internet Explorer. Learn more here Delphi Automotive @ DelphiAuto ...

Delphi Connect for Verizon on the App Store on iTunes
Get Delphi Connect for Verizon on the App Store. See screenshots and ratings, and read customer reviews.


Audi working with Delphi to develop autonomous car tech
Audi is developing an iPad-sized device that will pack all the necessary computing power for a self-driving car

US approves China company's acquisition of Delphi biz
The Committee on Foreign Investment in the United States has formally approved the acquisition of Delphi's global production of braking systems ...

Verizon And Delphi Officially Launch Vehicle Diagnostics Service - $250 For The Module, $5 A Month On ...
If you're a car nut, a paranoid parent, or a small business owner looking to do a little, uh, company vehicle economy analysis, Verizon's teamed ...

Watch out Google: Delphi gives Ars a ride in its self-driving car
The automotive components maker gave Ars a preview ride around the neighborhood. MOUNTAIN VIEW, CA—On Thursday morning I met with Delphi at its ...

The skinny on Delphi's autonomous road trip across the United States
Filed under: Green , Videos , Autonomous Last week, Delphi's autonomous car became the first to complete a coast-to-coast trip across the United ...

Delphi partners with WiTricity on automated wireless charging system
One could easily argue that parking between the white lines at any local hangout presents a challenge for some inexperienced drivers. So, why ...

Resources last updated: 12/16/2015 8:16:42 PM