Downloading multiple files?
Downloading multiple files?
Downloading multiple files?
Downloading multiple files?
Downloading multiple files?
Downloading multiple files? Downloading multiple files? Downloading multiple files? Downloading multiple files? Downloading multiple files? Downloading multiple files? Downloading multiple files? Downloading multiple files?
Downloading multiple files? Downloading multiple files?
Downloading multiple files?
Go Back  Xtreme Visual Basic Talk > > > Downloading multiple files?


Reply
 
Thread Tools Display Modes
  #1  
Old 02-21-2012, 07:34 PM
evanx93 evanx93 is offline
Newcomer
 
Join Date: Feb 2012
Posts: 7
Default Downloading multiple files?


I am having problems making a program that will downloads direct links and puts it into one of the users folder. I trying to make to so you click a button and it download the files. Any help would be helpful thanks.
Reply With Quote
  #2  
Old 05-03-2012, 02:42 AM
dorianus dorianus is offline
Regular
 
Join Date: May 2006
Posts: 69
Default

if you have ftp connection to the target files, you can use the following code:
Code:
    Private Sub Download(ByVal filePath As String, ByVal fileName As String)
        FTPSettings.IP = "ftp.myftp.com/folder"
        FTPSettings.UserID = "UserID"
        FTPSettings.Password = "Password"
        Dim reqFTP As FtpWebRequest = Nothing
        Dim ftpStream As Stream = Nothing
        Try
            Dim outputStream As New FileStream(filePath + "\" + fileName, FileMode.Create)
            reqFTP = DirectCast(FtpWebRequest.Create(New Uri("ftp://" + FTPSettings.IP + "/" + fileName)), FtpWebRequest)
            reqFTP.Method = WebRequestMethods.Ftp.DownloadFile
            reqFTP.UseBinary = True
            reqFTP.Credentials = New NetworkCredential(FTPSettings.UserID, FTPSettings.Password)
            Dim response As FtpWebResponse = DirectCast(reqFTP.GetResponse(), FtpWebResponse)
            ftpStream = response.GetResponseStream()
            Dim cl As Long = response.ContentLength
            Dim bufferSize As Integer = 2048
            Dim readCount As Integer
            Dim buffer As Byte() = New Byte(bufferSize - 1) {}

            readCount = ftpStream.Read(buffer, 0, bufferSize)
            While readCount > 0
                outputStream.Write(buffer, 0, readCount)
                readCount = ftpStream.Read(buffer, 0, bufferSize)
            End While

            ftpStream.Close()
            outputStream.Close()
            response.Close()
        Catch ex As Exception
            If ftpStream IsNot Nothing Then
                ftpStream.Close()
                ftpStream.Dispose()
            End If
            Throw New Exception(ex.Message.ToString())
        End Try
    End Sub
Code:
Public NotInheritable Class FTPSettings
        Private Sub New()
        End Sub
        Public Shared Property IP() As String
            Get
                Return m_IP
            End Get
            Set(ByVal value As String)
                m_IP = value
            End Set
        End Property
        Private Shared m_IP As String
        Public Shared Property UserID() As String
            Get
                Return m_UserID
            End Get
            Set(ByVal value As String)
                m_UserID = value
            End Set
        End Property
        Private Shared m_UserID As String
        Public Shared Property Password() As String
            Get
                Return m_Password
            End Get
            Set(ByVal value As String)
                m_Password = value
            End Set
        End Property
        Private Shared m_Password As String
    End Class
__________________
"Take my Future, Past, its fine, but Now is mine."
K's Choice
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Downloading multiple files?
Downloading multiple files?
Downloading multiple files? Downloading multiple files?
Downloading multiple files?
Downloading multiple files?
Downloading multiple files? Downloading multiple files? Downloading multiple files? Downloading multiple files? Downloading multiple files? Downloading multiple files? Downloading multiple files?
Downloading multiple files?
Downloading multiple files?
 
Downloading multiple files?
Downloading multiple files?
 
-->