This project is read-only.

Documentation/General Library Use

Mar 29, 2012 at 6:18 AM

I would like to start by saying that this library appears to be exactly what I have been looking for.  I can't stand using the FtpWebRequest class that is built in to the .NET library. 

That said, is there some documentation on basic use of this library?  I have created the API documentation using the supplied Sandcastle Documentation files and loaded it into my VS2008 document cache, but there appears to be a lot missing, including examples.  In general, I am trying to figure out how to connect to an FTP server using SSL/TLS (explicit), determine if there are files available in a given directory (outbound) on the server, and, if so, download them all and then remove them from the server.  In turn, using the same connection, I will need to potentially transfer files to a different directory (inbound) on the server. 

Thanks in advance,

Jim Marciniak

Mar 30, 2012 at 10:33 PM
Edited Mar 30, 2012 at 10:37 PM

Hi Jim,

The sandcastle docs are probably (mostly at least) inaccurate. I haven't updated any of them in a while. There is no real documentation short of what's in the Documentation section of the site. I know that's a big issue however I haven't had the time to really sit down and write any (I've had a lot going on with work and with personal time).

To do what you have described you will want to make use of the FtpDirectoryInfo and FtpFileInfo classes. In the FtpClient object, there exists an object named CurrentDirectory which is a FtpDirectoryInfo object. The properties of the two classes should be mostly self explanatory.

In regards to SSL, the Explicit option will setup a secure stream once the connection is made (before credentials are sent) using the AUTH TLS/SSL command. This method will fall back to no encryption in the event that the server doesn't support. There are two events in FtpClient that you need to handle: InvalidCertificate and SecurityNotAvailable. The invalid certificate is fired when there is a problem with the SSL certificate (name mismatch, un-trusted authority, etc...). The event args will allow you to cancel out an exception being thrown. The SecurityNotAvailable event is fired when the server doesn't support AUTH TLS/SSL and the event args have a property that allow you to abort the connection before credentials are sent in plain text to the server.

The Implicit SSL option assumes you are connecting to a port on the server setup for SSL only (typically 990). It uses a secure stream straight from the start however the added value over Explicit SSL  in terms of security is probably debatable since nothing of substantial value is exchanged between the client and server in plain text when Explicit SSL is used if you handle the SecurityNotAvailable event properly.

With that said, either implicit or explicit security are viable options. Use the one that fits your use case.

Sorry for the late response, let me know if you have any other questions. If you send me an email via the codeplex contact option in my profile I can probably dig up some more complete examples from my test code.