我在Indy网站上下了一个关于TIdFTP的demo,其中有这么一句:FTP.Get(FileName, SaveFile.FileName, true, true);总是报错'destination file already exists',明明目录下没有那个文件。如是我看看get实现的源码procedure TIdFTP.Get(const ASourceFile: string; ADest: TIdStream; AResume: Boolean = False);
begin
//for SSL FXP, we have to do it here because InternalGet is used by the LIST command
//where SSCN is ignored.
ClearSSCN;
AResume := AResume and CanResume;
ADest.Position := 0;
InternalGet('RETR ' + ASourceFile, ADest, AResume);
end;procedure TIdFTP.Get(const ASourceFile, ADestFile: string; const ACanOverwrite: boolean = False;
AResume: Boolean = false);
var
LDestStream: TIdStream;
begin AResume := AResume and CanResume;
if ACanOverwrite and (not AResume) then begin
Sys.DeleteFile(ADestFile);
LDestStream := TFileCreateStream.Create(ADestFile);
end else begin
if (not ACanOverwrite) and AResume then
begin
LDestStream := TAppendFileStream.Create(ADestFile);
end
else
begin
raise EIdFTPFileAlreadyExists.Create(RSDestinationFileAlreadyExists);
end;
end; try
Get(ASourceFile, LDestStream, AResume);
finally
Sys.FreeAndNil(LDestStream);
end;
end;我看了raise EIdFTPFileAlreadyExists.Create(RSDestinationFileAlreadyExists);之前的代码发现get方法的后两个boolean参数不能相同啊,即不能同时为true或false,不能既覆盖又重传(可以接受),不能不覆盖不重传,但默认的两个参数的值是两个false,这是怎么搞的嘛?还想问一个问题:TIdFTP如何支持sftp呢?我看它有这个属性FUsingSFTP : Boolean;但是它是只读属性,没办法啊。
begin
//for SSL FXP, we have to do it here because InternalGet is used by the LIST command
//where SSCN is ignored.
ClearSSCN;
AResume := AResume and CanResume;
ADest.Position := 0;
InternalGet('RETR ' + ASourceFile, ADest, AResume);
end;procedure TIdFTP.Get(const ASourceFile, ADestFile: string; const ACanOverwrite: boolean = False;
AResume: Boolean = false);
var
LDestStream: TIdStream;
begin AResume := AResume and CanResume;
if ACanOverwrite and (not AResume) then begin
Sys.DeleteFile(ADestFile);
LDestStream := TFileCreateStream.Create(ADestFile);
end else begin
if (not ACanOverwrite) and AResume then
begin
LDestStream := TAppendFileStream.Create(ADestFile);
end
else
begin
raise EIdFTPFileAlreadyExists.Create(RSDestinationFileAlreadyExists);
end;
end; try
Get(ASourceFile, LDestStream, AResume);
finally
Sys.FreeAndNil(LDestStream);
end;
end;我看了raise EIdFTPFileAlreadyExists.Create(RSDestinationFileAlreadyExists);之前的代码发现get方法的后两个boolean参数不能相同啊,即不能同时为true或false,不能既覆盖又重传(可以接受),不能不覆盖不重传,但默认的两个参数的值是两个false,这是怎么搞的嘛?还想问一个问题:TIdFTP如何支持sftp呢?我看它有这个属性FUsingSFTP : Boolean;但是它是只读属性,没办法啊。
解决方案 »
- 一个关于vc++中函数返回值类型在delphi中的声明问题!
- Tmonthcalendar控件,如何把日期设置成2004-05-01的形式
- 任何让TDateTimePicker显示当天的日期
- 关于多线程的困惑!
- 谢谢老兄,那怎么样打开一个本地的网页呢?ShellExecute(Handle, 'Open', 'IEXPLORE.EXE', 'Http://haitian.myrice.com', 1)
- 求助,VB写的Dll怎样在Delphi中调用
- 继续讨论头疼的格式---单引号问题
- 我想请教一下, 我用delphi打印, 能不能控制column detail 打印的行数,比如每页打印10行??
- 誰給我說說TNMSMTP控件的ONSTATUS何時触發?
- 关于SQL Server服务管理器的小问题。
- 如何 遍历 cxGrid 过滤(filter) 后的结果
- 登陆窗口消失的问题
AResume断点续传
用ACanOverwrite就不用AResume
indy 不支持SFTP的。想想其它辦法吧。
或者改成Winsock
可行。呵呵。從原生SOCKET去做。 INDY不支持這個協議。