Click here to Skip to main content
13,200,202 members (55,613 online)
Click here to Skip to main content
Add your own
alternative version


12 bookmarked
Posted 5 May 2007

A simple backup maker for your programs' folders

, 5 May 2007
Rate this:
Please Sign up or sign in to vote.
An application for backing up from your programs' folders.


This article is for building a simple console application that makes backup of your application folder periodically (daily and/or monthly, for example) by using the Windows Scheduled Tasks. In this application, you can also filter some folders (Bin or images, for example) or some file extensions (.pdb or .user, for example), or yet avoid some files from being backed up.


You can use the Windows Scheduled Tasks for running some tasks periodically or just once. It's available through the Accessories->System Tools menu entry. You can specify an executable file (js file in this project) to run in a periodical manner or just once.

I'll use the js file as an executable file because you can change it simply by using Notepad, this is the known extension for system administrators who make administration scripts with it. I also use the namespace in .NET2.0 for making zipping backups. This namespace is better than System.IO.Compression because of its ability to add new entries to a Zip file.

Using the code

It's just a simple application including two files; one is the ZipClass that wraps the classes and another is the main program class that has some static methods to make backups. The Main method is the starting point of the console application and its pick parameters from the command line (we can pass them through the cmd.exe utility or the way I do in js files with the Execute method of WScript.Shell).

static void Main(string[] args) { 
    string argFilePath; 
    if (args.Length > 0 && !string.IsNullOrEmpty(args[0]) 
                        && File.Exists(args[0]) ) 
The Main method in this application accepts a parameter that specifies the file path of the running parameter (running configuration). I used the ".prm" for the extension of these files but it's completely optional. The parameter file is an XML file that looks like:

As you see, this file acts as a configuration file; you specify the source and destination path, and also the filters you want to apply. And finally, you should create a js file for each backup policy with content like this (this is if the previous parameter file is named "MonthlyBackupMaker.prm"):

var oShell = new ActiveXObject("WScript.Shell"); 
oShell.Exec("BackupMaker.exe MonthlyBackupMaker.prm");

Everything is done now; you should simply add a scheduled job to run this js file monthly, for example.

If you specify the type "RootFolder" as in the above example (versus "FileOnly"), then the application test source sub-folder (first level) LastWriteTime will be less than the last backup date.

static bool FolderIsExpired(DirectoryInfo DirInf)
    if (DirInf.LastWriteTime >= perviousBackUpDate)
        return true;
    return false;


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


About the Author

Mehran Farshadmehr
Australia Australia
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralError On Page Pin
Member 300257923-Jun-08 23:35
memberMember 300257923-Jun-08 23:35 

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171020.1 | Last Updated 5 May 2007
Article Copyright 2007 by Mehran Farshadmehr
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid