Delphi解析FTP地址的方法
作者:互联网
2025-08-27
本文实例讲述了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程序设计有所帮助。
相关标签:
Delphi教程
相关推荐
专题
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
最新数据
相关文章
修改 Delphi 10.3.3 IDE 字体和字体大小
08/31
Delphi 3.0中连接数据库的三种方式
08/31
Oralce 调用Delphi写DLL去访问C# WebService的问题
08/31
一个C++及Delphi做的压缩程序
08/31
怎样在C#中调用Delphi6写的DLL
08/31
关于C#下写的Web Service 服务在Delphi下调用时的问题
08/31
在Delphi中的Access技巧集
08/31
传递和返回数据到一个Delphi编写的UDF
08/31
如何用Delphi和Web Services开发短信应用程序
08/30
如何用Delphi实现StringTokenizer功能
08/30
AI精选
