请问如何在DELPHI中实现向指定FTP服务器传送文件,请给代码,我很菜的。谢谢各位大侠了?在线等

解决方案 »

  1.   

    以下是简单的例子,使用的是Delphi 6中提供的FTP控件!!!仅供参考!!!Var
       FTP      : TNMFTP;
       FileName : String;
       Done     : Integer;
       Rec      : TSearchRec;
       Path     : String;
    begin
         FTP := TNMFTP.Create( Nil );
         Try
            FTP.Host     := FTPConfig.Host;
            FTP.Port     := FTPConfig.Port;
            FTP.UserID   := FTPConfig.User;
            FTP.Password := FTPConfig.Password;
            Try
               FTP.Connect;
               Path := ExtractFilePath( ParamStr( 0 ) ) + 'FUCAIT' + Copy( DataDate, 1, 4 ) + Copy( DataDate, 6, 2 ) + Copy( DataDate, 9, 2 ) + '01*.*';
               Done := FindFirst( Path, faAnyFile, Rec );
               While Done = 0 Do
               Begin
                     FileName := ExtractFilePath( ParamStr( 0 ) ) + Rec.Name;
                     FTP.Upload( FileName, ExtractFileName( FileName ) );
                     Done := FindNext( Rec );
               End;
               FindClose( Rec );
               Path := ExtractFilePath( ParamStr( 0 ) ) + 'FUCAIP' + Copy( DataDate, 1, 4 ) + Copy( DataDate, 6, 2 ) + Copy( DataDate, 9, 2 ) + '01*.*';
               Done := FindFirst( Path, faAnyFile, Rec );
               While Done = 0 Do
               Begin
                     FileName := ExtractFilePath( ParamStr( 0 ) ) + Rec.Name;
                     FTP.Upload( FileName, ExtractFileName( FileName ) );
                     Done := FindNext( Rec );
               End;
               FindClose( Rec );
               FTP.Disconnect;
            Except
            End;
         Finally
                FTP.Free;
         End;
    end;
      

  2.   

    我用DELPHI7 怎么没有你讲的控件那
      

  3.   

    当然NM已经淘汰的!!用Indy吧,站点可下载Demo
    这个问题N次,不想再多说啦http://lysoft.7u7.net
      

  4.   

    可以给我一份DEMO吗?[email protected]