Delphi解析FTP地址的方法
更新時(shí)間:2015年05月08日 15:32:04 作者:xujh
這篇文章主要介紹了Delphi解析FTP地址的方法,涉及Delphi解析FTP的相關(guān)技巧,需要的朋友可以參考下
本文實(shí)例講述了Delphi解析FTP地址的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
procedure TForm1.FTPAnalysis(S:string;var UserName,Password,IP,FileName:String;var DirList:TStringList); var i,j:integer; strAuthorization,strAddr,strDirFile:string; //授權(quán)信息 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); //只取帳號(hào)密碼字段 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;
希望本文所述對(duì)大家的Delphi程序設(shè)計(jì)有所幫助。
相關(guān)文章
Delphi中使用ISuperObject解析Json數(shù)據(jù)的實(shí)現(xiàn)代碼
這篇文章主要介紹了Delphi中使用ISuperObject解析Json數(shù)據(jù)的實(shí)現(xiàn)代碼,需要的朋友可以參考下2017-09-09delphi中exit,abort,break,continue的區(qū)別介紹
本文詳細(xì)介紹下delphi中表示跳出的有break,continue, exit,abort, halt, runerror的區(qū)別,感興趣的朋友可以參考下哈,希望對(duì)你學(xué)習(xí)跳出有所幫助2013-04-04Delphi實(shí)現(xiàn)圖片滾動(dòng)切換的完整實(shí)例代碼
這篇文章主要介紹了Delphi實(shí)現(xiàn)圖片滾動(dòng)切換的完整實(shí)例代碼,通過本實(shí)例,讀者可以進(jìn)一步掌握Delphi控件及圖形處理的技巧,需要的朋友可以參考下2014-07-07Delphi實(shí)現(xiàn)窗口文字淡入淡出漸變效果的方法
這篇文章主要介紹了Delphi實(shí)現(xiàn)窗口文字淡入淡出漸變效果,需要的朋友可以參考下2014-07-07