Click here to Skip to main content
15,867,686 members
Articles / Programming Languages / C#

Application for uploading modified Files to a FTP Server

Rate me:
Please Sign up or sign in to vote.
4.73/5 (16 votes)
14 Oct 2002CPOL2 min read 199.8K   4.4K   80   24
Simple C# Console Application that uses a local MS-Access Database to store modification Dates of Files and uploads modified Files to a FTP Server

Introduction

This is a (greatly enhanced) .NET version of the code in my article "Perl Script for uploading modified files to a FTP-Server". Since most of the behaviour is completely the same, please read further details of the description in the article mentioned.

The whole purpose of the application is to upload files from your local Window PC (or LAN) to a FTP server or Windows file server, uploading only files and folders that you want (by a filter) and that actually changed since last upload (by comparing timestamp and filesize).

Installation

The application has no GUI at all, meaning that it is a .NET console application.

Before you use the FTPSync application the first time, please adjust the application-configuration in the file FtpSync.exe.config. This file is a regular .NET XML-configuration file; you can edit it with any text-editor.

Usage of the Application

The application is driven by configuration files with the file extension *.ftpsyncjob. E.g. MyWebsite.ftpsyncjob. You pass a configuration file as the first parameter when starting the application. These configuration files are XML, too.

The configuration files contain all the settings that are needed to upload files and folders to a FTP server. An example configuration file Example.ftpsyncjob is included in the downloads of this article. Open it in your prefered text editor and read the comments for a full description of all options.

History

In ascending order:

  • 2002-09-13 Initial release
  • 2002-09-14 Added Regular Expression support (see example .ftpsyncjob file)
  • 2002-10-12 Added more options, added multi-project support, added Windows-filesystem upload method support (in contrast to FTP upload method), renamed .ftpsync.config files to .ftpsyncjob files.

To mention...

The application is written in C# and is an enhanced version of the "FTP component written with fully managed code" by Alex Kwok. I enhanced it so that creation of FTP folders is possible and that the component handles virtual FTP folders on a Windows FTP server (which don't show up using the LIST FTP command). Thanks to Alex for the component!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer Zeta Software GmbH
Germany Germany
Uwe does programming since 1989 with experiences in Assembler, C++, MFC and lots of web- and database stuff and now uses ASP.NET and C# extensively, too. He has also teached programming to students at the local university.

➡️ Give me a tip 🙂

In his free time, he does climbing, running and mountain biking. In 2012 he became a father of a cute boy and in 2014 of an awesome girl.

Some cool, free software from us:

Windows 10 Ereignisanzeige  
German Developer Community  
Free Test Management Software - Intuitive, competitive, Test Plans.  
Homepage erstellen - Intuitive, very easy to use.  
Offline-Homepage-Baukasten

Comments and Discussions

 
GeneralMy vote of 1 Pin
Robin Saini4-May-11 23:19
Robin Saini4-May-11 23:19 
GeneralTo develop client server application for ftp Pin
b_men12312-Nov-06 20:02
b_men12312-Nov-06 20:02 
Generalbug at the getFileSize function Pin
hacx2k614-Oct-06 0:01
hacx2k614-Oct-06 0:01 
Generalthanks Pin
Shiva Varshovi8-Mar-05 21:25
Shiva Varshovi8-Mar-05 21:25 
GeneralRe: thanks Pin
smartentity3-Aug-05 21:14
smartentity3-Aug-05 21:14 
GeneralRe: thanks Pin
webleo25-Nov-05 2:36
webleo25-Nov-05 2:36 
QuestionHow to Move Files and Folders on a FTP server Pin
usman.Majeed22-Jul-04 20:35
usman.Majeed22-Jul-04 20:35 
AnswerRe: How to Move Files and Folders on a FTP server Pin
sharad_sharma_2k28-Sep-04 0:29
sharad_sharma_2k28-Sep-04 0:29 
AnswerRe: How to Move Files and Folders on a FTP server Pin
kapil Kumar Garg24-Jan-07 20:30
kapil Kumar Garg24-Jan-07 20:30 
Generalscript fails if any file is deleted from local directory. Pin
savya2-Jun-04 2:06
savya2-Jun-04 2:06 
GeneralI love your code! Pin
bli-6214-May-03 16:22
bli-6214-May-03 16:22 
Smile | :) Hi Uwe,

Thanks you very very much for your component/codes. I love it very much. Smile | :)

I was told to write a program for my boss to upload files to our clients. I have tested three ftp server, one is fine other two are fail. The program was broken at following line (ControlChannel.cs)

m_connection.Connect(m_server, m_port);

the warning message are like these

A first chance exception of type 'System.Net.Sockets.SocketException' occurred in system.dll

Additional information: The requested name is valid and was found in the database, but it does not have the correct associated data being resolved for
Confused | :confused:

It sounds that the program can't build a ftp connection. These FTP address are correct because I have tested them with WS-FTP software.

If I use the following simple codes, I can setup connection.

TcpClient tcpClient = new TcpClient();
try
{
tcpClient.Connect("ftp.fdch.com", 21);
}
catch (Exception e1 )
{
Console.WriteLine(e1.ToString());
}


I think there is some problem to set connection using your class.

Uwe, is there any guy know what is wrong and how to fix the problem?

Thank you very much again!



Bin Li
Reed Business Information
GeneralHey Uwe Pin
Brian Delahunty10-Apr-03 9:05
Brian Delahunty10-Apr-03 9:05 
GeneralDead link Pin
MrEyes25-Mar-03 0:37
MrEyes25-Mar-03 0:37 
GeneralBugs Pin
zhoulhh22-Feb-03 20:23
zhoulhh22-Feb-03 20:23 
QuestionAny bugs found/fixed? Pin
Matt Philmon21-Feb-03 8:41
Matt Philmon21-Feb-03 8:41 
AnswerRe: Any bugs found/fixed? Pin
Uwe Keim21-Feb-03 8:45
sitebuilderUwe Keim21-Feb-03 8:45 
GeneralLovely stuff Pin
Paul Watson17-Oct-02 2:10
sitebuilderPaul Watson17-Oct-02 2:10 
GeneralRe: Lovely stuff Pin
Uwe Keim17-Oct-02 2:17
sitebuilderUwe Keim17-Oct-02 2:17 
QuestionMissing Files ? Pin
Kant15-Oct-02 6:30
Kant15-Oct-02 6:30 
AnswerRe: Missing Files ? Pin
Uwe Keim15-Oct-02 6:39
sitebuilderUwe Keim15-Oct-02 6:39 
GeneralIssues... But really cool idea Pin
Laurent Kempé13-Sep-02 10:12
Laurent Kempé13-Sep-02 10:12 
GeneralRe: Issues... But really cool idea Pin
Uwe Keim14-Sep-02 0:02
sitebuilderUwe Keim14-Sep-02 0:02 
GeneralRe: Issues... But really cool idea Pin
Laurent Kempé14-Sep-02 0:43
Laurent Kempé14-Sep-02 0:43 
GeneralRe: Issues... But really cool idea Pin
Uwe Keim14-Sep-02 0:05
sitebuilderUwe Keim14-Sep-02 0:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.