Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET C#3.5
Hi,
I want to download a complete folder with its files from ftp server.
 
For Example, there is a folder "hello" with 3 files and 1 directory "subfolder" which has one file in it.
Posted 14-Oct-11 2:29am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

1) Request a list of files and folders in the target folder
2) Download each file separately.
3) Repeat 1) and 2) for the subfolders.
  Permalink  
v2
Comments
sethupathiram at 14-Oct-11 7:38am
   
Plzzz tell the logic How do need to write the function.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Simon Bang is totally right.
Anyway, I use the following recursive approach (which is pretty much the same)
(keep in mind that this is just sample code to illustrate the logic):
 

        public void DownloadFtpFolder(string ftpFolderPath)
        {
            FtpFolder fo = new FtpFolder(folderPath);
            foreach (FtpFile fi in fo.FtpFiles)
            {
                DownloadFtpFile(fi.FtpFilePath);
            }
            foreach (FtpFolder f in fo.FtpFolders)
            {
                DownloadFolder(f.FtpFolderpath);
            }
        }
        public void DownloadFtpFile(string ftpFilePath)
        {
            // download the file here
        }
 
You need a ftp library for downloading the actual files and navigating the folders, but I hope this illustrates how this could be done theoratically.
 
cheers
Andy
  Permalink  
v2
Comments
sethupathiram at 15-Oct-11 0:51am
   
Hi Could you plzz share me that ftp library files.
hoernchenmeister at 17-Oct-11 2:27am
   
We use a commercial library called IpWorks, but this approach applies to pretty much all other libs too.
I am pretty sure you might find a free library using google.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 14 Oct 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100