Das Beispiel in diesem Artikel beschreibt, wie Delphi FTP-Adressen analysiert. Teilen Sie es als Referenz mit allen. Die spezifische Implementierungsmethode ist wie folgt:
procedure TForm1.FTPAnalysis(S:string;var UserName,Password,IP,FileName:String;var DirList:TStringList);var i,j:integer; strAuthorization,strAddr,strDirFile:string; //Autorisierungsinformationen begin UserName:= ' anonym'; Passwort:= '[email protected]'; IP := ''; strAddr := Copy(S,7,length(S)-6); //Den Teil nach ftp:// abrufen //S-Format muss ähnlich wie ftp://rec:[email protected]/20050418/abcdef.vox sein, / /oder ftp://192.168.76.11/...... i := Pos('@',S); if(i>0) then begin strAuthorization := Copy(S,7,i-7); //Nur das Kontopasswortfeld übernehmen j:=Pos(':',strAuthorization); if(j<1)then exit; - 1); PassWord := Copy(strAuthorization,j+1,length(strAuthorization)-j); j:=Pos('/',strAddr); if(j>0) then IP := Copy(strAddr,i+1,ji-1);//Holen Sie sich die IP-Adresse strDirFile := Copy(strAddr,j+ 1 ,length(strAddr)-j); DirList.Delimiter := '/'; DirList.DelimitedText := strDirFile;//Get Directory List FileName := DirList[DirList.count-1];//Der letzte Teil ist der Dateiname DirList.Delete(DirList.Count-1);end;
Ich hoffe, dass dieser Artikel für alle bei der Delphi-Programmierung hilfreich sein wird.