代码如下,它为什么不执行错误处理,一发生错误运行就死掉呢?procedure TForm1.btcnClick(Sender: TObject);
begin
idftp1.Host:=edithost.Text;
idftp1.Port:=21;
idftp1.Username:=edit1.Text ;
idftp1.Password :=edit2.Text ;
try
idftp1.Connect() ;
except
showmessage('登陆信息错误!');
end
end;

解决方案 »

  1.   

    var
       filename,RemoteFile,path: String;
       idftp1: TNMFTP;
       S: TSaveDialog;
    begin
       idftp1 := TNMFTP.Create(nil);
       S := TSaveDialog.Create(nil);
       if idftp1.Connected then
           idftp1.Disconnect
       else
       begin
           idftp1.Host := '192.168.0.76';
           idftp1.Port := 21;
           idftp1.UserID := 'oracle';
           idftp1.Password := 'oracle';
           try
               idftp1.Connect();
           except
               Messagedlg('登陆信息错误!',mtCustom,[mbOk],0);
           end;
       end;
    这里没有出现死运行
      

  2.   

    idftpRecord.Disconnect;
       idftpRecord.Host := Host;
       idftpRecord.Port := Port;
       idftpRecord.Username := UserName;
       idftpRecord.Password := Password;
       try
          try
             idftpRecord.Connect(true);
          except
             on E: Exception do begin
                ErrorMsg := '连接Ftp服务器失败:' + E.Message;
                Result := false;
                Exit;
             end;
          end;
          try
             idftpRecord.Login;
          except
             on E: Exception do begin
                ErrorMsg := '登陆服务器失败:' + E.Message;
                Result := false;
                Exit;
             end;
          end;
       finally
       end;
       
       ErrorMsg := '连接FTP服务器成功';
       Result := true;