电脑爱好者,提供IT资讯信息及各类编程知识文章介绍,欢迎大家来本站学习电脑知识。 最近更新 | 联系我们 RSS订阅本站最新文章
电脑爱好者
站内搜索: 
当前位置:首页>> delphi技术>>delphi中一个解析FTP地址的小函数:

delphi中一个解析FTP地址的小函数

来源:www.cncfan.com | 2006-3-28 | (有3613人读过)

procedure TForm1.FTPAnalysis(S:string;var UserName,Password,IP,FileName:String;var DirList:TStringList);
var
i,j:integer;
strAuthorization,strAddr,strDirFile:string;//授权信息
begin
UserName:= 'anonymous';
Password:= 'test@test.com';
IP := '';
strAddr := Copy(S,7,length(S)-6);//取得ftp://之后的部分
//S 格式必须是类似ftp://rec:ooo@192.168.76.11/20050418/abcdef.vox,或ftp://192.168.76.11/......
i := Pos('@',S);
if(i>0) then
begin
strAuthorization := Copy(S,7,i-7); //只取帐号密码字段
j:=Pos(':',strAuthorization);
if(j<1)then
exit;
UserName := Copy(strAuthorization,1,j-1);
PassWord := Copy(strAuthorization,j+1,length(strAuthorization)-j);
end;
i := Pos('@',strAddr);
j:=Pos('/',strAddr);
if(j>0) then
IP := Copy(strAddr,i+1,j-i-1);//获得IP地址
strDirFile := Copy(strAddr,j+1,length(strAddr)-j);
DirList.Delimiter := '/';
DirList.DelimitedText := strDirFile;//获得目录列表
FileName := DirList[DirList.count-1];//最后部分为文件名
DirList.Delete(DirList.Count-1);

end;



作者Blog:http://blog.csdn.net/xujh/
delphi技术热门文章排行
网站赞助商
购买此位置

 

关于我们 | 网站地图 | 文档一览 | 友情链接| 联系我们

Copyright © 2003-2024 电脑爱好者 版权所有 备案号:鲁ICP备09059398号