views:

43

answers:

1

Hi all,

Was wondering if you could point me at a right direction on how to achieve this...

I'm currently working on an application that will check the filespace consumed in a remote FTP server that has folders, subfolders and files.

I managed to get some information using System.NET via FtpWebRequest, FtpResponse, WebRequestMethods & System.IO in my code. However, I'm stuck in how I could manage to traverse subdirectories using the said classes.

Was wondering if you could point me at the right direction on how I could achieve this using C#? Or if there are alternatives that I could use (i.e. powershell, windows command line, etc)? I've tried looking at Chillkat ftp2, but it is not free and some FTP client components have no documentation nor examples on how to use it.

Thank you.

A: 

You do this the same way you would download a file. Put the directory in the URL, then set the FtpWebRequest.Method property to WebRequestMethods.Ftp.ListDirectory. This will give you the list of files/subfolders, which you can then traverse manually.

Here's a blog post showing the process, as well as using ListDirectoryDetails to differentiate between files and subdirectories.

Reed Copsey
Thanks Reed. This is what I was looking for.
mallows98