How to download a file from FTP server?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: How to download a file from FTP server?

Hybrid View

  1. #1
    Join Date
    Oct 2013
    Posts
    5

    Thumbs up How to download a file from FTP server?

    Hi all,

    Can any one tell me how to donload a file from FTP server.
    ftp://ustr-erl-2103/

    I want a program for this in vb.net.

    Please help me out.

    Its urgent.


    Regards
    Seema

  2. #2
    Join Date
    Oct 2013
    Posts
    5

    Thumbs up Re: How to download a file from FTP server?

    hi

    Can any one plz correct my below code.....
    Code:
    
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
            Dim fwr As Net.FtpWebRequest = Net.FtpWebRequest.Create(ftp://ustr-erl-2103/)
            fwr.Credentials = New NetworkCredential("", "")
            fwr.KeepAlive = True
            fwr.Method = WebRequestMethods.Ftp.ListDirectory
            fwr.Proxy = Nothing
    
            Try
                Dim sr As New IO.StreamReader(fwr.GetResponse().GetResponseStream())
                Dim lst = sr.ReadToEnd().Split(vbNewLine)
                For Each file As String In lst
                    file = file.Trim() 'remove any whitespace
                    If file = ".." OrElse file = "." Then Continue For
                    Dim fwr2 As Net.FtpWebRequest = Net.FtpWebRequest.Create(ftpAddress & file)
                    fwr2.Credentials = fwr.Credentials
                    fwr2.KeepAlive = True
                    fwr2.Method = WebRequestMethods.Ftp.DownloadFile
                    fwr2.Proxy = Nothing
    
                    Dim fileSR As New IO.StreamReader(fwr2.GetResponse().GetResponseStream())
                    Dim fileData = fileSR.ReadToEnd()
                    fileSR.Close()
                Next
    
                sr.Close()
            Catch ex As Exception
            End Try
        End Sub
    End Class

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center