Delphi method to resolve FTP address _delphi

Source: Internet
Author: User
Tags ftp get ip

This article illustrates how Delphi resolves an ftp address. Share to everyone for your reference. The implementation method is as follows:

Procedure Tform1.ftpanalysis (S:string;var username,password,ip,filename:string;var dirlist:tstringlist);
 var I,j:integer;
 strauthorization,straddr,strdirfile:string;
 Authorization information begin username:= ' anonymous ';
 password:= ' test@test.com ';
 IP: = ';
 STRADDR: = Copy (S,7,length (S)-6); The partial//s format after obtaining ftp://must be similar to Ftp://rec:ooo@192.168.76.11/20050418/abcdef.vox,//or ftp://192.168.76.11/... I: = Pos ('
 @ ', S);
  if (i>0) THEN begin strauthorization: = Copy (s,7,i-7);
  Only take account password field 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);//Get IP address strdirfile: = Copy (Straddr,j+1,length (STRADDR)-j);
 Dirlist.delimiter: = '/'; Dirlist.delimitedtext: = strdirfile;//Get directory list filename: = dirlist[dirlist.count-1];//The last part is the filename dirlist.delete (
DIRLIST.COUNT-1); End

I hope this article will help you with your Delphi program.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.