Ftp Object : List Method |
Visual Basic |
---|
Public Sub List( _ Optional ByVal PathName As String _ ) |
Type should be ftpAscii or ftpEbcdic. If a value of ftpImage is specified then lines may not terminate with a CR/LF, creating a formatting problem.
This method sequences and sends the ftpType, ftpPort or ftpPassive, and ftpList commands.
If Timeout is greater than 0, List blocks until the listing is received or a ptTimeout error occurs. If Timeout is 0, List immediately returns and the Progress event fires multiple times as each reply is received.
This method may generate the following error code (refer to ErrorConstants for a complete list of error codes):
Private Sub Command1_Click() On Error Goto OnError ' use intrinsic error handling Ftp1.Login "ftp.dart.com", "anonymous", "powertcp" If Ftp1.State = tcpConnected Then MsgBox "Connected!" Exit Sub OnError: ' Any error jumps here Debug.Print "Error #" + CStr(Err.Number) + ": " + Err.Description End Sub Private Sub Command2_Click() On Error Goto OnError ' use intrinsic error handling Ftp1.Timeout = 1000 Ftp1.List "-lr" ' a full recursive listing is requested Text1.Text = Ftp1.Listing.Text ' show to user Exit Sub OnError: ' Any error jumps here Debug.Print "Error #" + CStr(Err.Number) + ": " + Err.Description End Sub Private Sub Command3_Click( On Error Goto OnError Ftp1.Timeout = 1000 Ftp1.List "-lr *.txt" ' a full recursive listing of text files Dim ListEntry As ListEntry For Each ListEntry In Ftp1.Listing Text2.Text = ListEntry.Name & vbCrLf ' show all names to user Next Exit Sub OnError: ' Any error jumps here Debug.Print "Error #" + CStr(Err.Number) + ": " + Err.Description End Sub