Click here to Skip to main content
15,889,433 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello

im haseeb

i want to download files from the folder/subfolder/<somefilename.extension> in ftp c#
ftp could online download files from the root folder i.e folder not from the child folder subfolder
how can i do that
can u plz send me some piece of code showing file download fron sub folder in ftp c#
ill be highly thankful to you
Posted

It's not like that.

You can just give path of the file contained in sub folder and you can
download the file from sub folder or any folder hierarchy.

Try following example.


C#
// Get the object used to communicate with the server.
//Instead of ftp://www.contoso.com/test.htm you can try
//ftp://www.contoso.com/folder/test.htm or you can also try
//ftp://www.contoso.com/folder/subfolder/subfolder/test.htm

            FtpWebRequest request =    
(FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/test.htm");
            request.Method = WebRequestMethods.Ftp.DownloadFile;

            // This example assumes the FTP site uses anonymous logon.
            request.Credentials = new NetworkCredential ("anonymous","janeDoe@contoso.com");

            FtpWebResponse response = (FtpWebResponse)request.GetResponse();
    
            Stream responseStream = response.GetResponseStream();
            StreamReader reader = new StreamReader(responseStream);
            Console.WriteLine(reader.ReadToEnd());

            Console.WriteLine("Download Complete, status {0}", response.StatusDescription);
    
            reader.Close();
            response.Close();



HTH
 
Share this answer
 
Have a look at these of how to have FTP in C#:
An FTP client library for .NET 2.0[^]
C# FTP Client Library[^]
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900