H
hongzenghuang
Unregistered / Unconfirmed
GUEST, unregistred user!
下面是我写的一个求指定文件的大小 用idftp 编译的时候没错 运行是给个url却总是提示
not logged in错误。在FileSize := IdFTP1.size(aurl);这个位置。请问connect不是已经就登录了么
function tform1.geturlhost(aurl:string):string;
var
i,a:integer;
s:string;
host: array[0..255] of Char;
begin
s:=aurl;
i:=pos('/',s);
a:=1;
while (i<>0) and (a<3)do
begin
delete(s,1,i);
i:=pos('/',s);
a:=a+1;
end;
i:=pos('/',s);
StrPLCopy(host,s,i-1);
result:=host;
end;
function TForm1.getfilesize(aurl: string): integer;
var
FileSize : integer;
begin
idftp1.Username:='nonymous';
idftp1.Password:='zh@21cn.com';
idftp1.Host :=geturlhost(aurl);
idftp1.Port :=21;
idftp1.Connect(true);
FileSize := IdFTP1.size(aurl);
showmessage(inttostr(filesize));
IdFTP1.Abort;
Result := FileSize;
except
showmessage('连接失败');
end;
end;
not logged in错误。在FileSize := IdFTP1.size(aurl);这个位置。请问connect不是已经就登录了么
function tform1.geturlhost(aurl:string):string;
var
i,a:integer;
s:string;
host: array[0..255] of Char;
begin
s:=aurl;
i:=pos('/',s);
a:=1;
while (i<>0) and (a<3)do
begin
delete(s,1,i);
i:=pos('/',s);
a:=a+1;
end;
i:=pos('/',s);
StrPLCopy(host,s,i-1);
result:=host;
end;
function TForm1.getfilesize(aurl: string): integer;
var
FileSize : integer;
begin
idftp1.Username:='nonymous';
idftp1.Password:='zh@21cn.com';
idftp1.Host :=geturlhost(aurl);
idftp1.Port :=21;
idftp1.Connect(true);
FileSize := IdFTP1.size(aurl);
showmessage(inttostr(filesize));
IdFTP1.Abort;
Result := FileSize;
except
showmessage('连接失败');
end;
end;