Var
  Name, Line: String;
  IsDirectory: Boolean;
begin
  if not IdFTP1.Connected then exit;
  if DirectoryList.ItemIndex=-1 then exit;
  Line := DirectoryList.Items[DirectoryList.ItemIndex];
  Name := GetNameFromDirLine(Line, IsDirectory);
  if IsDirectory then begin
    SetFunctionButtons(false);
    ChageDir(Name);
    SetFunctionButtons(true);
  end
  else begin
  try
    SaveDialog1.FileName := Name;
    if SaveDialog1.Execute then begin
    SetFunctionButtons(false);
    IdFTP1.TransferType := ftBinary;
    BytesToTransfer := IdFTP1.Size(Name);
    IdFTP1.Get(Name, SaveDialog1.FileName, true);
    end;
  finally
    SetFunctionButtons(true);
  end;
  end;
end; 本来是用上面的代码下载的,现在不想用SaveDialog1,直接给个物理路径保存文件,请问这段怎么改?

解决方案 »

  1.   


    Var
      Name, Line: String;
      IsDirectory: Boolean;
    begin
      if not IdFTP1.Connected then exit;
      if DirectoryList.ItemIndex=-1 then exit;
      Line := DirectoryList.Items[DirectoryList.ItemIndex];
      Name := GetNameFromDirLine(Line, IsDirectory);
      if IsDirectory then begin
        SetFunctionButtons(false);
        ChageDir(Name);
        SetFunctionButtons(true);
      end
      else begin
      try
        //SaveDialog1.FileName := Name;
        //if SaveDialog1.Execute then begin
        SetFunctionButtons(false);
        IdFTP1.TransferType := ftBinary;
        BytesToTransfer := IdFTP1.Size(Name);
        IdFTP1.Get(Name, '路径', true);
        end;
      finally
        SetFunctionButtons(true);
      end;
      end;
    end; 
      

  2.   

    原来是我路径的文件夹没建
     CreateDirectory('D:\temp',nil); 少了这个
    呵呵