How do I browse a FTP directory location in C# and download?-Urgen

G

Guest

Hi

Can someone please tell me how I can browse a FTP directory location in C#
and then download.

I am using something like:

DirectoryInfo DirInfo = new
DirectoryInfo("ftp://ftp.mysite.org/myftp/MYINBOUNDTEST");
FileInfo[] Files = DirInfo.GetFiles("*.asc");

This obviously is not correct as this will work for a local file path like
"c:\mysample".

Also, the code below won't work for me as it requires the filename in the
ServerUri.

WebClient request = new WebClient();
request.Credentials = new NetworkCredential("myftp", "mypwd");
request.DownloadFile(serverUri, "sample.txt.asc");

Just as an FYI, the FTP site also requires a login/pwd. If any idea pls.
reply asap.
 
V

V

Hi SDRoy,

You would need to implement (or borrow an existing class) which
implements the FTP Protocol. I know that in .Net 1.1 there is no class
available which provides the FTP protocol out-of-the-box. I am not sure
about the 2.0 version.

You need to implement sockets which communicate with the FTP Server
using the FTP Protocol.

I suggest you search on google for already existing code which people
have shared. One such exists at
http://www.codeproject.com/csharp/ftplib.asp

Hope that helped !

Regards,
Vaibhav
 
G

Guest

Thanks for the info. Forgot to mention that I am on .Net 2.0. So was trying
to get help as there are FTP Web Client classes in 2.0.
 
G

Guest

Thanks for the info. Forgot to mention that I am on .Net 2.0. So was trying
to get help as there are FTP Web Client classes in 2.0.
 
Top