[Delphi]一个解析FTP地址的小函数

2016-02-19 20:48 12 1 收藏

今天给大家分享的是由图老师小编精心为您推荐的[Delphi]一个解析FTP地址的小函数,喜欢的朋友可以分享一下,也算是给小编一份支持,大家都不容易啊!

【 tulaoshi.com - 编程语言 】

  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(i0) then
    begin
  
    strAuthorization := Copy(S,7,i-7); //只取帐号密码字段
      j:=Pos(':',strAuthorization);
      if(j1)then
        exit;
      UserName := Copy(strAuthorization,1,j-1);
      PassWord := Copy(strAuthorization,j+1,length(strAuthorization)-j);
    end;
    i := Pos('@',strAddr);
    j:=Pos('/',strAddr);
    if(j0) 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);

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

  end;

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

来源:https://www.tulaoshi.com/n/20160219/1624568.html

延伸阅读
标签: PHP
我的目标是去掉字符串中的空格,句号和逗号。 $str="hello baby,nice to meet you.hehe";//这样可以正确显示 $str="hello baby,nice to meet you . hehe";//如果在句号前面或后面多了个空格就会出现数组里某个键的值为空,也就是说当需要去掉的字符一起出现时,就会出现空值,这是为何,该如何解决? //我的一个方法是判断值是否...
标签: ASP
  asp中有很多的文章在研究如何提高asp程序的执行效率,我们 得出结论 在<% 和 % 之间的代码执行的速度要高于 在这个 标签之外的代码,我们有没有想过 如何重复的利用这些在标签之外的代码呢? 有的人可能觉得 这个没有什么意义!但是我们可以 怀着 一种很轻松的心态来看看下面这个例子,看看 我们得到了什么有趣的现象!在这个例子中,...
标签: Web开发
select id="Year" name="Year"option value=""/option/select年 select id="Month" name="Month"/select月 select id="Day" name="Day"/select日br / select id="iYear" name="iYear"option value=""/option/select年 select id="iMonth" name="iMonth"/select月select id...
using System; using System.Net; using System.IO; using System.Text; using System.Net.Sockets; namespace zhangyuk.net.csdn.blog.ftpclient {  /// <summary  /// FTP Client  /// </summary  public class FTPClient  {   #region 构造函数   /// <summary   /// 缺省构造函数  ...
标签: Web开发
很多语言都有类似php中的include和require功能的函数,而唯独javascript没有。  很早就想在js中实现类似的功能,尝试了很多次都没有成功,那天在google上搜索一些关于动态加载css文件的关键词时,发现一个blog(地址找不到了)上的一个为网页的head标签增加link元素的函数,于是就改了一下,写了这个函数。  用法:  include...

经验教程

701

收藏

25
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部