locked
Copy all files from folder on web RRS feed

  • Question

  • Hi! I have folder on server, and I am uploading files to that folder. For example I have folder on server with name patch! Now I want to download all files from 192.168.0.144\patch

    How I can do this?

    Thanks!

    Monday, October 4, 2010 8:22 AM

Answers

    • Marked as answer by Chao Kuo Monday, October 11, 2010 12:00 PM
    Monday, October 4, 2010 8:56 AM
  • Hello, Comii

    As Cor said you need to use a loop to find all the files and directories in your ftp websites, then you can download them one by one.

    I recommend you use a recursion to download all the files from the FTP websites.

    Please see the following sample code, which list all the files and folders in the ftp website.

     

            Dim request As FtpWebRequest = DirectCast(WebRequest.Create("ftp://10.172.18.116/"), FtpWebRequest)

            request.Method = WebRequestMethods.Ftp.ListDirectoryDetails

            Dim response As FtpWebResponse = DirectCast(request.GetResponse(), FtpWebResponse)

            Dim ResponseStream As Stream = response.GetResponseStream()

            Dim sr As StreamReader = New StreamReader(ResponseStream)

            While Not sr.EndOfStream

                Console.WriteLine(sr.ReadLine())

            End While

            response.Close()

    Hope this helps.

    Thanks

    Chao


    Please unmark it if it does not help, and mark it if it helps.
    • Marked as answer by Chao Kuo Monday, October 11, 2010 12:00 PM
    Thursday, October 7, 2010 7:33 AM

All replies

    • Marked as answer by Chao Kuo Monday, October 11, 2010 12:00 PM
    Monday, October 4, 2010 8:56 AM
  • Ok. But this is code for download single file, how i can download all files from folder! 

    If I use this code i need to know name of all file that i need to download!

     

     

    Monday, October 4, 2010 12:58 PM
  • That is obvious, you are not able to investigate a webserver in any way, that is restricted by almost all kind of newer OS systems.

    (In some older it is still possible, while it is also possible if you have set FTP on the server and use that FTP software).

    However, you wrote you have put the files yourselves on a folder of that server, so you can download them in a loop (and then implement threads what is very nice for an operation like this)

    This as long as you have http rights to the folder.

     


    Success
    Cor
    Tuesday, October 5, 2010 8:18 AM
  • Hello, Comii

    As Cor said you need to use a loop to find all the files and directories in your ftp websites, then you can download them one by one.

    I recommend you use a recursion to download all the files from the FTP websites.

    Please see the following sample code, which list all the files and folders in the ftp website.

     

            Dim request As FtpWebRequest = DirectCast(WebRequest.Create("ftp://10.172.18.116/"), FtpWebRequest)

            request.Method = WebRequestMethods.Ftp.ListDirectoryDetails

            Dim response As FtpWebResponse = DirectCast(request.GetResponse(), FtpWebResponse)

            Dim ResponseStream As Stream = response.GetResponseStream()

            Dim sr As StreamReader = New StreamReader(ResponseStream)

            While Not sr.EndOfStream

                Console.WriteLine(sr.ReadLine())

            End While

            response.Close()

    Hope this helps.

    Thanks

    Chao


    Please unmark it if it does not help, and mark it if it helps.
    • Marked as answer by Chao Kuo Monday, October 11, 2010 12:00 PM
    Thursday, October 7, 2010 7:33 AM