Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Error : The requested URI is invalid for this ftp command.
Website ftp://dennisproject.bugs3.com/Images/Fotos/Gallery/


Private Sub listFTP(ByVal URL As String, ByVal bk As String, ByVal pw As String)
        Dim requ As FtpWebRequest = Nothing
        Dim resp As FtpWebResponse = Nothing
        Dim reader As StreamReader = Nothing
        Try
            requ = CType(WebRequest.Create(URL), WebRequest)
            requ.Credentials = New NetworkCredential(bk, pw)
            resp = CType(requ.GetResponse(), FtpWebResponse)
            reader = New StreamReader(resp.GetResponseStream())
            While (reader.Peek() > -1)
                ListBox1.Items.Add(reader.ReadLine())
            End While
            StatusBar1.Text = "Refresh Succeed!"
        Catch ex As UriFormatException
            MsgBox(ex.Message)
        Catch ex As WebException
            MsgBox(ex.Message)
        Finally
            If reader IsNot Nothing Then reader.Close()
        End Try

    End Sub
Posted

1 solution

You never define the FTP command you want to execute (Method property of FtpWebRequest) so it runs the default command, which is DownloadFile...You gave in your URL a path to a folder and not to a file...FTP can not download all files in a folder with a single DownloadFile command...
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 22-Mar-15 14:16pm    
Good catch, a 5.
—SA
Kornfeld Eliyahu Peter 22-Mar-15 14:23pm    
Thank you...
Member 11268652 22-Mar-15 14:52pm    
i want the file list into a listbox so all images. not download XD
Kornfeld Eliyahu Peter 22-Mar-15 15:21pm    
So set Method to ListDirectory...
phil.o 22-Mar-15 18:38pm    
You can find all methods available for a FtpWebRequest here.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900