Tuesday, August 6, 2013

.NET Program to copy files into multiple locations (on Periodic basis)

Hi All,

So, this other day, I needed a program to copy the files from prod server to Dev, and I had to do this for an entire week. The issue is, I have to do it over multiple locations, over a period of time. I wrote a simple .NET program to solve this.. I hope it is useful to you as well..

If you don't care about the source, just want to use this program, you can install it from here : Link . 
Note: If you cannot get to the link above, it means your organization / admin has blocked google drive. Please reach out to me directly - Dinesh.Loganathan {at} g mail{dot} com
Edit : You might get a Microsoft smart screen warning, if you are using Windows 8, please ignore that and select "Proceed Anyway" to install the program.

Program's Features:

  1. Ability to Run in the background (File-> Run in background)
  2. Ability to save the settings, so that it can be retrieved during next launch. Save the settings @ {File-> Save}
  3. Ability to schedule the copy based on pattern {just put in the HH, MM Fields with hour and minute you want the schedule to be executed}
  4. Ability to copy only the files created today {Recent files only column}
  5. Ability to overwrite the files automatically {Overwrite?} column
  6. Add multiple copy tasks by adding new rows.
Since I needed something quick, I had developed this program using C# & WinForms.

Step 1 :

Add a data set which takes care of the configuration settings. Please note that there are other ways of doing this, I just did what was easy. I am persisting the settings on to user's appdata folder. Add a new table by clicking on the Table properly and add the below columns:




Step 2: 

Add a GridView control and have it linked to the Data set that we had created.Apart from the auto generated columns, also add a link button column, I am calling it "Run"



Step 3:
Add a notification icon, Menu strip and do the coding for that. {You can refer to the source file}




Step 4:

Write the below code for a class called "DataSetSettings":
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;
using System.Data;
namespace FileCopyMultiDestinations
{
public class DataSetSettings
{

public string FromPath{get;set;}
public string ToPath { get; set; }
public string Pattern { get; set; }
public bool isEnabled{get;set;}
public bool isScheduled{get;set;}
public bool isOverWrite{get;set;}
public bool isTodaysFilesOnly { get; set; }
public int iSchMM { get; set; }
public int iSchHH { get; set; }
public bool isTodaysFileOnly { get; set; }

public static DataSetSettings ParseDataRow(DataRow dr)
{
    DataSetSettings Return = new DataSetSettings();


    string FromPath, ToPath, Pattern;
    bool isEnabled, isScheduled, isOverWrite,isTodaysFileOnly;
    int iSchMM, iSchHH;

    FromPath = dr["FromPath"].ToString();
    ToPath = dr["ToPath"].ToString();
    Pattern = dr["Pattern"].ToString();
    bool.TryParse(dr["SettingEnabled"].ToString(), out isEnabled);
    bool.TryParse(dr["OverWrite"].ToString(), out isOverWrite);
    bool.TryParse(dr["Schedule"].ToString(), out isScheduled);
    int.TryParse(dr["RunTimeHour"].ToString(), out iSchHH);
    int.TryParse(dr["RunTimeMinute"].ToString(), out iSchMM);
    bool.TryParse(dr["RecentFileOnly"].ToString(), out isTodaysFileOnly);

    Return.FromPath = FromPath;
    Return.ToPath = ToPath;
    Return.Pattern = Pattern;
    Return.isEnabled = isEnabled;
    Return.isOverWrite = isOverWrite;
    Return.isScheduled = isScheduled;

    Return.iSchHH = iSchHH;
    Return.iSchMM = iSchMM;
    Return.isTodaysFileOnly = isTodaysFileOnly;
    return Return;
}
}
}


Write below code for Logging {I am using NLog, since it is easy to use, you can also use custom logging or Log4NET or whatever you are comfortable with}: 


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;
using NLog;
namespace FileCopyMultiDestinations
{
public class Log
{

    static protected Logger ThisLogger { get; set; }
    static Log()
    {
        LogManager.ReconfigExistingLoggers();
           
        ThisLogger = LogManager.GetCurrentClassLogger();
    }

    public static void LogMessage(string strMessage, LogLevel Level)
    {
        if (Level == LogLevel.Debug)
        {
            ThisLogger.Debug(strMessage);
        }
        else if (Level == LogLevel.Info)
        {
            ThisLogger.Info(strMessage);
        }
        else if (Level == LogLevel.Trace)
        {
            ThisLogger.Trace(strMessage);
        }
        else if (Level == LogLevel.Warn)
        {
            ThisLogger.Warn(strMessage);
        }
        else if (Level == LogLevel.Error)
        {
            ThisLogger.Error(strMessage);
        }
        else if (Level == LogLevel.Fatal)
        {
            ThisLogger.Fatal(strMessage);
        }
        else
        {
            ThisLogger.Info(strMessage);
        }
    }

    public static void LogMessage(string strMessage)
    {
        LogMessage(strMessage, LogLevel.Debug);
    }
}

}


Write below code for the Windows Form Form:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;
using System.Windows.Forms;
using System.Configuration;
using System.IO;

namespace FileCopyMultiDestinations
{
    public partial class frmMain : Form
    {
public frmMain()
{
InitializeComponent();
}

private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.Visible = true;
}

private void frmMain_Load(object sender, EventArgs e)
{
//notifyIcon1.
Log.LogMessage("Application Starting..");
InitAppSettingsFolder();
LoadSettings();
           
}

private void InitAppSettingsFolder()
{
string AppFolderName =  Environment.GetFolderPath( Environment.SpecialFolder.LocalApplicationData) +@"\"+ ConfigurationManager.AppSettings["AppName"];
try
{
    if (!Directory.Exists(AppFolderName))
    {
        Directory.CreateDirectory(AppFolderName);
    }
}
catch (Exception ex)
{
    Log.LogMessage(ex.Message);
    MessageBox.Show(this, "Error - " + ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
}
private void LoadSettings()
{
try
{
    string strFileName = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\" + ConfigurationManager.AppSettings["AppName"];
    if (!strFileName.EndsWith(@"\"))
    {
        strFileName = strFileName + @"\";
    }
    strFileName = strFileName +ConfigurationManager.AppSettings["DatasetFileName"];
    try
    {
                   
        //runInBackgroundToolStripMenuItem.Checked =
        dsListOfAllSettings.ReadXml(strFileName);
        Log.LogMessage("Successfully loaded the settings..");
        runInBackgroundToolStripMenuItem.Checked = Properties.Settings.Default.RunInBackGround;
    }
    catch (
        Exception ex1)
    {
        Log.LogMessage("Reinitializing the settings, since : " + ex1.Message);
        dsListOfAllSettings.WriteXml(strFileName);
        MessageBox.Show("Reinit of settings complete!");
    }
               
             
}
catch (Exception ex)
{
    Log.LogMessage(ex.Message);
    MessageBox.Show(this, "Error - " + ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
}

private void SaveSettings()
{
try
{
    dataGridView1.EndEdit();
    string strFileName = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\" + ConfigurationManager.AppSettings["AppName"];
    if (!strFileName.EndsWith(@"\"))
    {
        strFileName = strFileName + @"\";
    }
    strFileName = strFileName + ConfigurationManager.AppSettings["DatasetFileName"];
    dsListOfAllSettings.WriteXml(strFileName);
    Properties.Settings.Default.Save();
    Log.LogMessage("Successfully saved all the settings..");
}
catch (Exception ex)
{
    Log.LogMessage(ex.Message);
    MessageBox.Show(this, "Error - " + ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
}

private void runInBackgroundToolStripMenuItem_Click(object sender, EventArgs e)
{
if (runInBackgroundToolStripMenuItem.Checked)
{
    runInBackgroundToolStripMenuItem.Checked = false;
}
else
{
    runInBackgroundToolStripMenuItem.Checked = true;
}
}
///

///
///

///
///
private void tmrTicks_Tick(object sender, EventArgs e)
{
Ticker();
}

private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
{
Log.LogMessage("Application close/minimize detected!");
if (runInBackgroundToolStripMenuItem.Checked)
{
    Log.LogMessage("Pulling the app to background!");
    e.Cancel = true;
    this.Visible = false;
}
}

private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.ExitThread();
}

private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
Log.LogMessage("Save setting start!");
SaveSettings();
Log.LogMessage("Save setting end!");
}

private void frmMain_FormClosed(object sender, FormClosedEventArgs e)
{
Log.LogMessage("Application Exitting!");
SaveSettings();
}

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 9)
{
    Log.LogMessage("Manual Run Detetected!");
    DataRow dr = tblSettings.Rows[e.RowIndex];
    if (dr != null)
    {
        DataSetSettings oCurrSettings = DataSetSettings.ParseDataRow(dr);
        if (!oCurrSettings.FromPath.Trim().Equals(string.Empty) && !oCurrSettings.ToPath.Trim().Equals(string.Empty))
        {
            Log.LogMessage("Manual Run Start!");
            CopyFiles(oCurrSettings.FromPath, oCurrSettings.ToPath, oCurrSettings.Pattern, oCurrSettings.isOverWrite, oCurrSettings.isTodaysFileOnly);
            Log.LogMessage("Manual Run End!");
            MessageBox.Show("Operation Completed!", "Complete");
        }

    }
}
}

private void Ticker()
{
try
{
    Log.LogMessage("Timer Tick Started");
    int iCurrentHH, iCurrentMM;
    iCurrentHH = DateTime.Now.Hour;
    iCurrentMM = DateTime.Now.Minute;
    List<DataSetSettings> oListToRun = new List<DataSetSettings>();
    foreach (DataRow dr in tblSettings.Rows)
    {
        DataSetSettings oCurrSettings = DataSetSettings.ParseDataRow(dr);

        if (oCurrSettings.isEnabled && !oCurrSettings.FromPath.Trim().Equals(string.Empty) && !oCurrSettings.ToPath.Trim().Equals(string.Empty))
        {
            if (oCurrSettings.isScheduled)
            {
                if (oCurrSettings.iSchMM == iCurrentMM && oCurrSettings.iSchHH == iCurrentHH)
                {
                    oListToRun.Add(oCurrSettings);
                }
            }
        }
    }
               
    foreach (DataSetSettings oCurrSettings in oListToRun)
    {
        CopyFiles(oCurrSettings.FromPath, oCurrSettings.ToPath, oCurrSettings.Pattern, oCurrSettings.isOverWrite, oCurrSettings.isTodaysFileOnly);
    }

    Log.LogMessage("Timer Tick Ended");
}
catch (Exception ex)
{
    Log.LogMessage("Error During Timer Tick!");
    Log.LogMessage(ex.Message, NLog.LogLevel.Error);
    throw ex;
}
       
}

private void CopyFiles(string SourcePath, string DestinationPath, string Pattern, bool Overwrite, bool isTodaysFileOnly)
{
try
{
    DirectoryInfo oDI = new DirectoryInfo(SourcePath);
    if (!DestinationPath.EndsWith(@"\"))
        DestinationPath = DestinationPath + @"\";

    foreach (FileInfo oFI in oDI.GetFiles(Pattern))
    {
        DateTime LastModifiedTime = oFI.LastWriteTime;
        if (!isTodaysFileOnly ||
            (LastModifiedTime.Date == DateTime.Now.Date && isTodaysFileOnly))
        {
            if (File.Exists(DestinationPath + oFI.Name) && !Overwrite)
            {
                DialogResult oRes =
                        MessageBox.Show(this, "File : " + DestinationPath + oFI.Name + " already exists..\nPress Yes for Overwriting the current file No For leaving current file at destination alone, cancel for skipping currnet operation", "Confirm", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation);
                if (oRes == System.Windows.Forms.DialogResult.Yes)
                {
                    oFI.CopyTo(DestinationPath + oFI.Name, true);
                }
                else if (oRes == System.Windows.Forms.DialogResult.Cancel)
                {
                    break;
                }
            }
            else
            {
                oFI.CopyTo(DestinationPath + oFI.Name, Overwrite);
            }
        }
    }

}
catch (Exception ex)
{
    Log.LogMessage(ex.Message, NLog.LogLevel.Error);
    throw ex;
}
}
}
}

Application Config file:
xml version="1.0"?>
<configuration>
  <configSections>
      <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
          <section name="FileCopyMultiDestinations.Properties.Settings"                      type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
                    allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
      </sectionGroup>
  </configSections>
  <startup>
       
  <supportedRuntime version="v2.0.50727"/></startup>
<appSettings>
  <add key="DatasetFileName" value="DataSet.xml"/>
  <add key="AppName" value="MultiFileCopy"/>
</appSettings>
<userSettings>
  <FileCopyMultiDestinations.Properties.Settings>
    <setting name="RunInBackGround" serializeAs="String">
      <value>False</value>
    </setting>
    <setting name="Setting" serializeAs="String">
      <value>test</value>
    </setting>
  </FileCopyMultiDestinations.Properties.Settings>
</userSettings>
</configuration>


 NLog Config File:

xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    autoReload="true"
    throwExceptions="false">
  
  <variable name="ApplicationName" value="MultiFileCopy" />
<variable name="LogDirectory" value="${specialfolder:folder=LocalApplicationData}\${ApplicationName}\Logs"/>
  <targets>
  <target xsi:type="File"
          name="File"           
          layout="${longdate} - ${level} - ${logger} - ${message}"
          fileName="${LogDirectory}\${ApplicationName}.log"
          archiveFileName="${LogDirectory}\${ApplicationName}_${shortdate}.{##}.log"
          keepFileOpen="true"
          archiveNumbering="Sequence"
          archiveEvery="Day"
          maxArchiveFiles="30"
          />
  <target xsi:type="ColoredConsole"
      name="Console"           
          layout="${longdate} - ${level:uppercase=true}: ${message}"
  
  />
</targets>
 
<rules>
  <logger name="*" writeTo="File,Console" minlevel="Debug" />
</rules>
</nlog>


Form's Designer code:
namespace FileCopyMultiDestinations
{
partial class frmMain
{
    ///

    /// Required designer variable.
    ///

    private System.ComponentModel.IContainer components = null;

    ///

    /// Clean up any resources being used.
    ///

    /// true if managed resources should be disposed; otherwise, false.
    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }

    #region Windows Form Designer generated code

    ///

    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    ///

    private void InitializeComponent()
    {
        this.components = new System.ComponentModel.Container();
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain));
        this.dataGridView1 = new System.Windows.Forms.DataGridView();
        this.dsListOfAllSettings = new System.Data.DataSet();
        this.tblSettings = new System.Data.DataTable();
        this.ColumnisSettingEnabled = new System.Data.DataColumn();
        this.ColumnFromPath = new System.Data.DataColumn();
        this.ColumnToPath = new System.Data.DataColumn();
        this.ColumnPattern = new System.Data.DataColumn();
        this.ColumnisSchedule = new System.Data.DataColumn();
        this.ColumnMM = new System.Data.DataColumn();
        this.ColumnHH = new System.Data.DataColumn();
        this.ColumnisOverWrite = new System.Data.DataColumn();
        this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
        this.mnuMenu = new System.Windows.Forms.MenuStrip();
        this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.runInBackgroundToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.tmrTicks = new System.Windows.Forms.Timer(this.components);
        this.ColumnRecentFileOnly = new System.Data.DataColumn();
        this.settingEnabledDataGridViewCheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
        this.fromPathDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
        this.toPathDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
        this.patternDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
        this.scheduleDataGridViewCheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
        this.runTimeHourDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
        this.runTimeMinuteDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
        this.RecentFileOnly = new System.Windows.Forms.DataGridViewCheckBoxColumn();
        this.OverWrite = new System.Windows.Forms.DataGridViewCheckBoxColumn();
        this.Run = new System.Windows.Forms.DataGridViewLinkColumn();
        ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.dsListOfAllSettings)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.tblSettings)).BeginInit();
        this.mnuMenu.SuspendLayout();
        this.SuspendLayout();
        //
        // dataGridView1
        //
        this.dataGridView1.AutoGenerateColumns = false;
        this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
        this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
        this.settingEnabledDataGridViewCheckBoxColumn,
        this.fromPathDataGridViewTextBoxColumn,
        this.toPathDataGridViewTextBoxColumn,
        this.patternDataGridViewTextBoxColumn,
        this.scheduleDataGridViewCheckBoxColumn,
        this.runTimeHourDataGridViewTextBoxColumn,
        this.runTimeMinuteDataGridViewTextBoxColumn,
        this.RecentFileOnly,
        this.OverWrite,
        this.Run});
        this.dataGridView1.DataMember = "tblSettings";
        this.dataGridView1.DataSource = this.dsListOfAllSettings;
        this.dataGridView1.Location = new System.Drawing.Point(16, 33);
        this.dataGridView1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
        this.dataGridView1.Name = "dataGridView1";
        this.dataGridView1.Size = new System.Drawing.Size(1453, 638);
        this.dataGridView1.TabIndex = 0;
        this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
        //
        // dsListOfAllSettings
        //
        this.dsListOfAllSettings.DataSetName = "dsListOfAllSettings";
        this.dsListOfAllSettings.Locale = new System.Globalization.CultureInfo("en-US");
        this.dsListOfAllSettings.Tables.AddRange(new System.Data.DataTable[] {
        this.tblSettings});
        //
        // tblSettings
        //
        this.tblSettings.Columns.AddRange(new System.Data.DataColumn[] {
        this.ColumnisSettingEnabled,
        this.ColumnFromPath,
        this.ColumnToPath,
        this.ColumnPattern,
        this.ColumnisSchedule,
        this.ColumnMM,
        this.ColumnHH,
        this.ColumnisOverWrite,
        this.ColumnRecentFileOnly});
        this.tblSettings.TableName = "tblSettings";
        //
        // ColumnisSettingEnabled
        //
        this.ColumnisSettingEnabled.Caption = "SettingEnabled";
        this.ColumnisSettingEnabled.ColumnName = "SettingEnabled";
        this.ColumnisSettingEnabled.DataType = typeof(bool);
        //
        // ColumnFromPath
        //
        this.ColumnFromPath.Caption = "FromPath";
        this.ColumnFromPath.ColumnName = "FromPath";
        //
        // ColumnToPath
        //
        this.ColumnToPath.Caption = "ToPath";
        this.ColumnToPath.ColumnName = "ToPath";
        //
        // ColumnPattern
        //
        this.ColumnPattern.Caption = "Pattern";
        this.ColumnPattern.ColumnName = "Pattern";
        //
        // ColumnisSchedule
        //
        this.ColumnisSchedule.Caption = "Schedule";
        this.ColumnisSchedule.ColumnName = "Schedule";
        this.ColumnisSchedule.DataType = typeof(bool);
        //
        // ColumnMM
        //
        this.ColumnMM.Caption = "RunTimeMinute";
        this.ColumnMM.ColumnName = "RunTimeMinute";
        this.ColumnMM.DataType = typeof(short);
        //
        // ColumnHH
        //
        this.ColumnHH.Caption = "RunTimeHour";
        this.ColumnHH.ColumnName = "RunTimeHour";
        this.ColumnHH.DataType = typeof(short);
        //
        // ColumnisOverWrite
        //
        this.ColumnisOverWrite.Caption = "Overwrite?";
        this.ColumnisOverWrite.ColumnName = "OverWrite";
        this.ColumnisOverWrite.DataType = typeof(bool);
        //
        // notifyIcon1
        //
        this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
        this.notifyIcon1.Text = "AutoFileCopier";
        this.notifyIcon1.Visible = true;
        this.notifyIcon1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseDoubleClick);
        //
        // mnuMenu
        //
        this.mnuMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
        this.fileToolStripMenuItem});
        this.mnuMenu.Location = new System.Drawing.Point(0, 0);
        this.mnuMenu.Name = "mnuMenu";
        this.mnuMenu.Padding = new System.Windows.Forms.Padding(8, 2, 0, 2);
        this.mnuMenu.Size = new System.Drawing.Size(1485, 28);
        this.mnuMenu.TabIndex = 2;
        this.mnuMenu.Text = "menuStrip1";
        //
        // fileToolStripMenuItem
        //
        this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
        this.runInBackgroundToolStripMenuItem,
        this.saveToolStripMenuItem,
        this.exitToolStripMenuItem});
        this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
        this.fileToolStripMenuItem.Size = new System.Drawing.Size(44, 24);
        this.fileToolStripMenuItem.Text = "File";
        //
        // runInBackgroundToolStripMenuItem
        //
        this.runInBackgroundToolStripMenuItem.Checked = true;
        this.runInBackgroundToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
        this.runInBackgroundToolStripMenuItem.Name = "runInBackgroundToolStripMenuItem";
        this.runInBackgroundToolStripMenuItem.Size = new System.Drawing.Size(202, 24);
        this.runInBackgroundToolStripMenuItem.Text = "Run in Background";
        this.runInBackgroundToolStripMenuItem.Click += new System.EventHandler(this.runInBackgroundToolStripMenuItem_Click);
        //
        // saveToolStripMenuItem
        //
        this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
        this.saveToolStripMenuItem.Size = new System.Drawing.Size(202, 24);
        this.saveToolStripMenuItem.Text = "&Save";
        this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
        //
        // exitToolStripMenuItem
        //
        this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
        this.exitToolStripMenuItem.Size = new System.Drawing.Size(202, 24);
        this.exitToolStripMenuItem.Text = "E&xit";
        this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
        //
        // tmrTicks
        //
        this.tmrTicks.Enabled = true;
        this.tmrTicks.Interval = 60000;
        this.tmrTicks.Tick += new System.EventHandler(this.tmrTicks_Tick);
        //
        // ColumnRecentFileOnly
        //
        this.ColumnRecentFileOnly.Caption = "RecentFileOnly";
        this.ColumnRecentFileOnly.ColumnName = "RecentFileOnly";
        this.ColumnRecentFileOnly.DataType = typeof(bool);
        //
        // settingEnabledDataGridViewCheckBoxColumn
        //
        this.settingEnabledDataGridViewCheckBoxColumn.DataPropertyName = "SettingEnabled";
        this.settingEnabledDataGridViewCheckBoxColumn.HeaderText = "Enabled?";
        this.settingEnabledDataGridViewCheckBoxColumn.Name = "settingEnabledDataGridViewCheckBoxColumn";
        this.settingEnabledDataGridViewCheckBoxColumn.Width = 60;
        //
        // fromPathDataGridViewTextBoxColumn
        //
        this.fromPathDataGridViewTextBoxColumn.DataPropertyName = "FromPath";
        this.fromPathDataGridViewTextBoxColumn.HeaderText = "FromPath";
        this.fromPathDataGridViewTextBoxColumn.Name = "fromPathDataGridViewTextBoxColumn";
        this.fromPathDataGridViewTextBoxColumn.Width = 300;
        //
        // toPathDataGridViewTextBoxColumn
        //
        this.toPathDataGridViewTextBoxColumn.DataPropertyName = "ToPath";
        this.toPathDataGridViewTextBoxColumn.HeaderText = "ToPath";
        this.toPathDataGridViewTextBoxColumn.Name = "toPathDataGridViewTextBoxColumn";
        this.toPathDataGridViewTextBoxColumn.Width = 300;
        //
        // patternDataGridViewTextBoxColumn
        //
        this.patternDataGridViewTextBoxColumn.DataPropertyName = "Pattern";
        this.patternDataGridViewTextBoxColumn.HeaderText = "Pattern";
        this.patternDataGridViewTextBoxColumn.Name = "patternDataGridViewTextBoxColumn";
        this.patternDataGridViewTextBoxColumn.Width = 70;
        //
        // scheduleDataGridViewCheckBoxColumn
        //
        this.scheduleDataGridViewCheckBoxColumn.DataPropertyName = "Schedule";
        this.scheduleDataGridViewCheckBoxColumn.HeaderText = "Sch?";
        this.scheduleDataGridViewCheckBoxColumn.Name = "scheduleDataGridViewCheckBoxColumn";
        this.scheduleDataGridViewCheckBoxColumn.Width = 50;
        //
        // runTimeHourDataGridViewTextBoxColumn
        //
        this.runTimeHourDataGridViewTextBoxColumn.DataPropertyName = "RunTimeHour";
        this.runTimeHourDataGridViewTextBoxColumn.HeaderText = "HH";
        this.runTimeHourDataGridViewTextBoxColumn.Name = "runTimeHourDataGridViewTextBoxColumn";
        this.runTimeHourDataGridViewTextBoxColumn.Width = 40;
        //
        // runTimeMinuteDataGridViewTextBoxColumn
        //
        this.runTimeMinuteDataGridViewTextBoxColumn.DataPropertyName = "RunTimeMinute";
        this.runTimeMinuteDataGridViewTextBoxColumn.HeaderText = "MM";
        this.runTimeMinuteDataGridViewTextBoxColumn.Name = "runTimeMinuteDataGridViewTextBoxColumn";
        this.runTimeMinuteDataGridViewTextBoxColumn.Width = 40;
        //
        // RecentFileOnly
        //
        this.RecentFileOnly.DataPropertyName = "RecentFileOnly";
        this.RecentFileOnly.HeaderText = "RecentFileOnly";
        this.RecentFileOnly.Name = "RecentFileOnly";
        this.RecentFileOnly.Width = 50;
        //
        // OverWrite
        //
        this.OverWrite.DataPropertyName = "OverWrite";
        this.OverWrite.HeaderText = "OverWrite";
        this.OverWrite.Name = "OverWrite";
        this.OverWrite.Width = 60;
        //
        // Run
        //
        this.Run.HeaderText = "Run";
        this.Run.Name = "Run";
        this.Run.ReadOnly = true;
        this.Run.Text = "Run";
        this.Run.UseColumnTextForLinkValue = true;
        this.Run.Width = 40;
        //
        // frmMain
        //
        this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(1485, 686);
        this.Controls.Add(this.dataGridView1);
        this.Controls.Add(this.mnuMenu);
        this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
        this.MainMenuStrip = this.mnuMenu;
        this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
        this.Name = "frmMain";
        this.Text = "Copy Files from source to Destination";
        this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmMain_FormClosing);
        this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.frmMain_FormClosed);
        this.Load += new System.EventHandler(this.frmMain_Load);
        ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
        ((System.ComponentModel.ISupportInitialize)(this.dsListOfAllSettings)).EndInit();
        ((System.ComponentModel.ISupportInitialize)(this.tblSettings)).EndInit();
        this.mnuMenu.ResumeLayout(false);
        this.mnuMenu.PerformLayout();
        this.ResumeLayout(false);
        this.PerformLayout();

    }

    #endregion

    private System.Windows.Forms.DataGridView dataGridView1;
    private System.Data.DataSet dsListOfAllSettings;
    private System.Windows.Forms.NotifyIcon notifyIcon1;
    private System.Windows.Forms.MenuStrip mnuMenu;
    private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem runInBackgroundToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
    private System.Data.DataTable tblSettings;
    private System.Data.DataColumn ColumnisSettingEnabled;
    private System.Data.DataColumn ColumnFromPath;
    private System.Data.DataColumn ColumnToPath;
    private System.Data.DataColumn ColumnPattern;
    private System.Data.DataColumn ColumnisSchedule;
    private System.Data.DataColumn ColumnMM;
    private System.Data.DataColumn ColumnHH;
    private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
    private System.Windows.Forms.Timer tmrTicks;
    private System.Data.DataColumn ColumnisOverWrite;
    private System.Data.DataColumn ColumnRecentFileOnly;
    private System.Windows.Forms.DataGridViewCheckBoxColumn settingEnabledDataGridViewCheckBoxColumn;
    private System.Windows.Forms.DataGridViewTextBoxColumn fromPathDataGridViewTextBoxColumn;
    private System.Windows.Forms.DataGridViewTextBoxColumn toPathDataGridViewTextBoxColumn;
    private System.Windows.Forms.DataGridViewTextBoxColumn patternDataGridViewTextBoxColumn;
    private System.Windows.Forms.DataGridViewCheckBoxColumn scheduleDataGridViewCheckBoxColumn;
    private System.Windows.Forms.DataGridViewTextBoxColumn runTimeHourDataGridViewTextBoxColumn;
    private System.Windows.Forms.DataGridViewTextBoxColumn runTimeMinuteDataGridViewTextBoxColumn;
    private System.Windows.Forms.DataGridViewCheckBoxColumn RecentFileOnly;
    private System.Windows.Forms.DataGridViewCheckBoxColumn OverWrite;
    private System.Windows.Forms.DataGridViewLinkColumn Run;
}
}

If you don't care about the source, just want to use this program, you can install it from here : Link

Source code of this program is here : Link
License - Microsoft Public license - http://www.microsoft.com/en-us/openness/licenses.aspx

Visual studio express edition {For Desktop} can be downloaded here : http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-for-windows-desktop#product-express-desktop