发现Indy9和Indy10(10.0.52版本)里的IdFTP.Size()返回值的类型都是Integer的,也就是说文件最大不能超过2G,需要进入IdFTP.Pas里修改, 声明的地方: function Size(const AFileName: String): Integer; //修改Integer-->Int64 实现的地方: function TIdFTP.Size(const AFileName: String): Integer; //修改Integer-->Int64 var SizeStr: String; begin result := -1; if SendCmd('SIZE ' + AFileName) = 213 then begin {do not localize} SizeStr := Trim(LastCmdResult.Text.Text); IdDelete(SizeStr, 1, IndyPos(' ', SizeStr)); // delete the response {do not localize} result := StrToIntDef(SizeStr, -1); //修改StrToIntDef-->StrToInt64Def end; end;同样在把IdFTP.Size()得到的值,赋给你的自定义变量时,也需要Int64类型。这样只要文件不超过{(2的63次方)-1 }都是没问题的。
同意楼上的分析,应是数据类型的问题,用int64
版本 10.2.3 单元 idftp.pas function TIdFTP.Size(const AFileName: String): Int64; var SizeStr: String; begin Result := -1; if SendCmd('SIZE ' + AFileName) = 213 then begin {do not localize} SizeStr := Trim(LastCmdResult.Text.Text); IdDelete(SizeStr, 1, IndyPos(' ', SizeStr)); // delete the response {do not localize} Result := IndyStrToInt64(SizeStr, -1); end; end; 已经是int64类型 可还是返回错误 所以来发问 !
你可以跟踪呀 size 这个函数 返回值就是 int64 的
但是 值不对
声明的地方:
function Size(const AFileName: String): Integer; //修改Integer-->Int64
实现的地方:
function TIdFTP.Size(const AFileName: String): Integer; //修改Integer-->Int64
var
SizeStr: String;
begin
result := -1;
if SendCmd('SIZE ' + AFileName) = 213 then begin {do not localize}
SizeStr := Trim(LastCmdResult.Text.Text);
IdDelete(SizeStr, 1, IndyPos(' ', SizeStr)); // delete the response {do not localize}
result := StrToIntDef(SizeStr, -1); //修改StrToIntDef-->StrToInt64Def
end;
end;同样在把IdFTP.Size()得到的值,赋给你的自定义变量时,也需要Int64类型。这样只要文件不超过{(2的63次方)-1 }都是没问题的。
function TIdFTP.Size(const AFileName: String): Int64;
var
SizeStr: String;
begin
Result := -1;
if SendCmd('SIZE ' + AFileName) = 213 then begin {do not localize}
SizeStr := Trim(LastCmdResult.Text.Text);
IdDelete(SizeStr, 1, IndyPos(' ', SizeStr)); // delete the response {do not localize}
Result := IndyStrToInt64(SizeStr, -1);
end;
end;
已经是int64类型 可还是返回错误 所以来发问 !
而且不同文件也一样返回-1,估计是因为sendcmd <> 213,但没办法去证明