Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to count files of FTP root directory with its sub directories files.
Posted
Comments
Garth J Lancaster 30-Mar-13 19:25pm    
What FTP Client are you using ? Often a FTP Client will have methods to get a list of files from a current directory or get a list of files from a current directory and sub-dirs - it depends on the client. If you only get a list from the current directory, you need to recurse through the list for all sub-directories found.
Sergey Alexandrovich Kryukov 30-Mar-13 20:51pm    
There is no need in any client, as .NET FCL's FtpWebRequest class plays the role of a client. Please see my answer.
—SA
Garth J Lancaster 30-Mar-13 20:58pm    
SAK>>FtpWebRequest class plays the role of a client

So apart from contradicting yourself, it IS a 'client' as opposed to a server - I wanted to know what mechanism he was using to access the FTP server, and, the common terminolgy for that, wether .NET FCL's FtpWebRequest or other, is a CLIENT

thank you so much for your comment
Sergey Alexandrovich Kryukov 30-Mar-13 21:08pm    
Agree, but seeing a contradiction here is casuistic. The class will become a client if used in some OP's application. When I say a client is not needed, I mean the client YOU mean, as something which is supposed to be used before answering the question. Such thing is no applicable and not needed.
—SA
Friendsaa 31-Mar-13 2:36am    
I am using FileZilla Client, To show progress of downloading files i want to count files, I downloaded files using FtpWebRequest.

1 solution

You can do it using the class System.Net.FtpWebRequest:
http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx[^].

The FTP command you need is System.Net.WebRequestMethods.Ftp.ListDirectory. For all of the commands, please see:
http://msdn.microsoft.com/en-us/library/system.net.webrequestmethods.ftp.aspx[^].

—SA
 
Share this answer
 
Comments
Friendsaa 31-Mar-13 3:40am    
I already did this, My question is how could i count files to show the progress in progressbar, Upto Downloading files i finished.
Sergey Alexandrovich Kryukov 31-Mar-13 11:25am    
No, you asked how to count file. And it looks like you know how to download. Everything else is your UI, but you did not ask it and did not even tag UI library you are using. Want to ask a related UI question?
—SA

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