How do I download all files in a directory and all subdirectories on an HTTP server?
Thanks!
How do I download all files in a directory and all subdirectories on an HTTP server?
Thanks!
By using a command-line tool like wget rather than reinventing the wheel.
If directory browsing is enabled on the server then you can crawl the directory listings, i.e. Use HttpWebRequest to get the listing page, parse the response to find the file links, download each file (also with HttpWebRequest), navigate to each subfolder, rinse and repeat.
If directory browsing isn't enabled then you can't really download ALL files in ALL subdirectories because you can't know they exist.
However, you could still use HttpWebRequest to crawl the exposed web pages and download any linked files that are of interest.