Greg
Greg

Reputation:

C# Download all files in HTTP directory

How do I download all files in a directory and all subdirectories on an HTTP server?

Upvotes: 3

Views: 8022

Answers (2)

stucampbell
stucampbell

Reputation: 6603

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.

Upvotes: 3

Andy Lester
Andy Lester

Reputation: 93815

By using a command-line tool like wget rather than reinventing the wheel.

Upvotes: 4

Related Questions