473,405 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Downloading all files in directory using FTP

20
Hello,

I am trying to download not one, but all files within a remote directory using FTP and C# and then save them to a local folder on my hard drive. How can I do this?

thanks
May 27 '09 #1
1 2782
tlhintoq
3,525 Expert 2GB
Get a list of all the files.
Add them to a list of files to be downloaded.
Loop through your list downloading one at a time.
When it is done, take it off you list of 'to be downloaded'
Next file on the list.

It's pretty much like your downloading of a single file, but with a 'foreach loop' wrapped around it.

Expand|Select|Wrap|Line Numbers
  1. List<string> FilesToDownload = new LIst<string>();
  2. FilesToDownload = GetTheFtpDirectoryContentsMethod(URLasStringParameter);//Returns a List
  3. foreach (string YogiBear in FilesToDownload)
  4. {
  5.      YourSingleFileDownloadMethod(YogiBear, LocalDestinationPath);
  6. }
  7.  

You probably want to do a few things like get the sizes of all the files to be downloaded and make sure there is sufficient room on the local directory. Do some checks that you can reach the source URL, that you have write permissions on the local destination and so on. Basic error handling stuff. But if you start with the stripped-down logic you can bolt on more and more armor until it's bullet proof.
May 27 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: PeterB | last post by:
Hi! I am using the script below to download files, that are in a non-public directory, from my site. The "smaller files" section works for smaller files. However when the files are getting...
7
by: Wardeaux | last post by:
Hey all, I'm hitting a wall... We have many daily reports generated on another server, need to present list of available files and allow user to download desired files from aspx page... any...
6
by: Shawn | last post by:
Hi. How can I download a file and store it on the web server. I have a complete URL to the file, but I never know what kind of file it is. It can be pdf, jpg, tif, doc, xls etc. Thanks, Shawn
2
by: Bala | last post by:
Hi I am trying to download the PDF files from my webserver using ASP.Net. All my files are stored at F Drive on webserver. Like this F:\Main Folder\Sub Folder\Files\File1.pdf I am...
1
by: Greg L. | last post by:
I apologize if this is not the correct group.... Using the system.net namespace I want to download an entire directory's worth of files. I've been researching furiously and can't seem to find...
4
by: KenFehling | last post by:
Hello. I am wondering if there exists a piece of software that takes multiple .js files that are nicely indented and commented and create one big tightly packed .js file. I'm hoping the one file...
3
by: xeroxero | last post by:
I would like to prevent people from downloading a .zip from a ASP.NET 2.0 web site, but still allow people to touch a .aspx page in the same directory. I also want to set things so if a user clicks...
6
by: David | last post by:
Is there a way to download a file from a directory not in the server's path? Eg. not under public_html? This would be for security so that the files can never be directly access vial the web. ...
3
by: bryanp10 | last post by:
I have a web application where the admin wants to be able to upload arbitrary files on an admin page... and then have them accessible for certain users. Easy enough eh? The difficulty I'm...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.