Delphi解析FTP地址 Delphi解析FTP地址的方法

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

Delphi解析FTP地址 Delphi解析FTP地址的方法

xujh   2021-03-21 我要评论
想了解Delphi解析FTP地址的方法的相关内容吗,xujh在本文为您仔细讲解Delphi解析FTP地址的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:Delphi,解析FTP地址,下面大家一起来学习吧。

本文实例讲述了Delphi解析FTP地址的方法。分享给大家供大家参考。具体实现方法如下:

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;

希望本文所述对大家的Delphi程序设计有所帮助。

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们