This topic demonstrates how to send items to an FTP server using the static Send method of the QuickFtp class.
Send method
The Send method has various overloads that can be used to send files to a server. Some only require that you specify the hostname, the destination folder, and the files to send, while others provide options such as using a username and password, authentication, whether or not to perform a recursive search, whether to replace existing files, preserve paths, proxies, passive transfers, synchronizing objects, etc. For details on the other overloads, see the reference documentation.
Demonstration
In the following example, we specify the hostname, a port number, a username and a password, the remote destination folder, various delegates for handling events, and the file to send (a recursive search is performed automatically). For more details on how to work with receiving certificates, see Xceed's Snippet Explorer.
VB.NET | Copy Code |
---|---|
|
C# | Copy Code |
---|---|
|
Remarks
When recursively sending adding files to a zip file, you have to consider every filename you place in the filesToSend parameter as a filemask. For example, if you set the filesToSend parameter to "c:\file.txt", the entire "c:\" drive will be scanned and all the files that are named "file.txt" that are found will be sent to the FTP server.
Note that the filesToSend parameter cannot be null; otherwise, an ArgumentNullException exception will be thrown.
Things you should consider
The main questions you should ask yourself when sending files to an FTP server are:
-
Do you want to do more complex FTP operations? Use the FileSystem-based classes defined within the Xceed.Ftp namespace.