Solved

c# download files from ftp

Posted on 2013-02-02
2
653 Views
Last Modified: 2013-02-21
I am creating a application in c# to download files from ftp and copy in my local computer.
If download folder contains directory i need create a same folder in my local computer and down load all the files from same folder.

i am using the following code for this. This is works fine when down folder does not contains any directory.  i do not know how to fetch the all directory name from ftp directory and create the same folder in my local drive. Please let me know how to achieve this ?



private void button2_Click(object sender, EventArgs e)
        {
         

            ftpDirectory = FtpServerName.ToString() + FtpPath.ToString();
            FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpDirectory);
            request.Credentials = new NetworkCredential(FtpUserName.ToString(), FtpPassword.ToString());
            request.Method = WebRequestMethods.Ftp.ListDirectory;

            StreamReader streamReader = new StreamReader(request.GetResponse().GetResponseStream());

            string fileName = "";

            while (fileName != null)
            {
               
                fileName = streamReader.ReadLine();
                if (fileName != null)
                {
                    string downLoadStatus = Download(FtpServerName.ToString(),
                     FtpPath.ToString(), fileName, localPath,
                        FtpUserName.ToString(), FtpPassword.ToString());
                }
            }

            request = null;
            streamReader = null;


         





        }
0
Comment
Question by:Varshini S
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 7

Accepted Solution

by:
tipsybroom earned 500 total points
ID: 38847431
0
 

Author Comment

by:Varshini S
ID: 38847745
ipsybroom -i need to check this in FTP folder not local drive
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question