FTP

April 2, 2009

C# FTP Demo

How to use the FTP functions built-in to C#

This is a more intermediate video.

What you will learn:
1) How to create a reuseable FTPFunction class library (with three static methods: Upload, Download, GetFileList.
2) How to call the function library from both a Windows form and a Console program.

First, I found some sample FTP code from this site:

http://aspalliance.com/1187_Building_a_Simple_FTP_Application_Using_C_20

I wrote the console program, because I wanted to schedule a nightly download from an FTP site in order to back-up an SQL server database backup (from my dedicated server to my laptop).

I decided to package the three routines in a class library, so it could be a shareable and reuseable DLL.
I then am able to call it from various other programs (and in the video, I do this from a Windows form, and a Console Command-Line program).

Once the code was packaged in the .DLL, it was easy to call it like this:

Code for you to copy:


    FTPFunctions.FTPFunctions.Download(FTPLocalPath,
                       FTPFilename,
                       FTPServer,
                       FTPUserid,
                       FTPPassword);

I created Download, Upload, and GetFileList as static methods, so they can be called without instantiating a class.

Two videos coming shortly…

Filed under FTP by Administrator

Permalink Print Comment