类似:
Copy ('c:\a.txt','ftp://username:[email protected]/aaa')要用WinAPI来实现。因为在资源管理器可以这么拷贝,一定有这样的函数

解决方案 »

  1.   

    用NMFTP1: TNMFTP;function TForm1.Connect_Proc(disp: Boolean): Boolean;
    begin
      Result := true;  NMFTP1.Disconnect;
      NMFTP1.Host     := FTPHost.Text;
      NMFTP1.Port     := StrToInt(FTPPort.Text);
      NMFTP1.UserID   := FTPUser.Text;
      NMFTP1.Password := FTPPassWD.Text;
      try
        NMFTP1.Connect;
        try
          NMFTP1.ChangeDir(trim(FTPPath.Text));
          if disp then MessageDlg('FTP OK',mtInformation,[mbOk], 0);
        except
          try
            NMFTP1.MakeDirectory(trim(FTPPath.Text));
            NMFTP1.ChangeDir(trim(FTPPath.Text));
            if disp then MessageDlg('FTP OK',mtInformation,[mbOk], 0);
          except
            on E: Exception do begin
              MessageDlg(E.Message, mtError, [mbOk], 0);
              Result := false;
            end;
          end;
        end;
      except
        on E: Exception do begin
          MessageDlg(E.Message, mtError, [mbOk], 0);
          Result := false;
        end;
      end;
    end;
    procedure TForm1.UpLoad_Proc;
    var RemoteFile: String;
    begin
      if not Connect_Proc(false) then exit;  try
        NMFTP1.ChangeDir(trim(FTPPath.Text)+'/cs'+YMD);
      except
        try
          NMFTP1.MakeDirectory(trim(FTPPath.Text)+'/cs'+YMD);
        except
          MessageDlg('Default path error!',mtError,[mbOk], 0);
          exit;
        end;
      end;  i := 0;
      NMFTP1.Mode(MODE_BYTE);  RemoteFile := File_Name(Rich_Output.Lines[i]);
      try
        NMFTP1.Upload(FileName,trim(FTPPath.Text) + RemoteFile);
      except
        NMFTP1.Disconnect;
        exit;
      end;  NMFTP1.Disconnect;
    end;