hey there, im reasonably new to C# and im currently writing a backup application which im using as a learning resource.
My PC :-
Visual Studio 2005
.NET Framework 2
Component Factory Krypton Tools
Test PC :-
.Net Framework 2
=============== =============== =============== =
The Issue:
On the testing PC, im receiving this error:
=============== =============== =============== =
=============== =============== =============== =
Now, I've copied all the Krypton DLL's into the runtime directory of the Backup application. but im not sure what in my code is causing this.
CODE:
=============== =============== =============== =
Any help would be greatly,greatly ,greatly appreciated
My PC :-
Visual Studio 2005
.NET Framework 2
Component Factory Krypton Tools
Test PC :-
.Net Framework 2
=============== =============== =============== =
The Issue:
On the testing PC, im receiving this error:
=============== =============== =============== =
Code:
System.NullReferenceException: Object reference not set to an instance of an object.
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at Backup.frmMain.ShowError(String title, String body)
at Backup.frmMain.Form1_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at ComponentFactory.Krypton.Toolkit.KryptonForm.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at ComponentFactory.Krypton.Toolkit.VisualForm.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
Backup
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///F:/Backup/Backup.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
ComponentFactory.Krypton.Toolkit
Assembly Version: 3.0.8.0
Win32 Version: 3.0.8.0
CodeBase: file:///F:/Backup/ComponentFactory.Krypton.Toolkit.DLL
Now, I've copied all the Krypton DLL's into the runtime directory of the Backup application. but im not sure what in my code is causing this.
CODE:
=============== =============== =============== =
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Threading;
using ComponentFactory.Krypton.Toolkit;
namespace Backup
{
public partial class frmMain : ComponentFactory.Krypton.Toolkit.KryptonForm
{
public int diff_x;
public int diff_y;
string USER_NAME = SystemInformation.UserName;
string DATE = Convert.ToString(System.DateTime.Now.Day + "-" + System.DateTime.Now.Month + "-" + System.DateTime.Now.Year);
string[,] UserDirs;
enum ext { dir, zip, exe, txt, pfd, xls, ppt, doc };
public frmMain()
{
UserDirs = new string[,]
{
{"Favorites", "C:\\Documents and Settings\\" + USER_NAME + "\\Favorites\\"},
{"Desktop", "D:\\USERDATA\\" + USER_NAME + "\\Desktop\\"},
{"Macros", "C:\\Documents and Settings\\" + USER_NAME + "\\Application Data\\Microsoft\\templates\\"},
{"Backups", "H:\\" + USER_NAME + " Backups\\"}
};
System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
InitializeComponent();
this.hdrTitleBar.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ButtonDown);
}
private long FreeHomeDriveSpace()
{
return 209715200 - (CalculateSize(new DirectoryInfo("H:\\")));
}
private bool CopyRecursiveFiles(DirectoryInfo d, string DestinationDirectory, bool CreateEmptyDir,string Extension)
{
try
{
if (CalculateSize(d) > FreeHomeDriveSpace())
{
ShowError("Error","You have insufficient space for copying");
return false;
}
else
{
FileInfo[] fis = d.GetFiles("*." + Extension);
// Create the destination directory, if CreateEmptyDir or contains files
if ((fis.Length > 0) || (CreateEmptyDir))
Directory.CreateDirectory(DestinationDirectory);
foreach (FileInfo fi in fis)
{
if(!File.Exists(DestinationDirectory + "\\" + fi.Name)) fi.CopyTo(DestinationDirectory + "\\" + fi.Name);
}
// Recursive copy children dirs
DirectoryInfo[] dis = d.GetDirectories();
foreach (DirectoryInfo di in dis)
{
CopyRecursiveFiles(di, DestinationDirectory + "\\" + di.Name, CreateEmptyDir, Extension);
}
Thread t = new Thread(Restore);
t.Start();
Thread h = new Thread(HDrive);
h.Start();
}
}
catch
{
return false;
}
return true;
}
private bool RestoreRecursiveFiles(DirectoryInfo d, string DestinationDirectory, bool CreateEmptyDir, string Extension)
{
try
{
FileInfo[] fis = d.GetFiles("*." + Extension);
// Create the destination directory, if CreateEmptyDir or contains files
if ((fis.Length > 0) || (CreateEmptyDir))
Directory.CreateDirectory(DestinationDirectory);
foreach (FileInfo fi in fis)
{
if (!File.Exists(DestinationDirectory + "\\" + fi.Name)) fi.CopyTo(DestinationDirectory + "\\" + fi.Name);
}
// Recursive copy children dirs
DirectoryInfo[] dis = d.GetDirectories();
foreach (DirectoryInfo di in dis)
{
CopyRecursiveFiles(di, DestinationDirectory + "\\" + di.Name, CreateEmptyDir, Extension);
}
Thread t = new Thread(Restore);
t.Start();
Thread h = new Thread(HDrive);
h.Start();
}
catch (Exception CopyErr)
{
return false;
}
return true;
}
private void BackupDir(DirectoryInfo Dir)
{
#region # Today Backup Check
if (!Directory.Exists(UserDirs[3,1] + DATE))
{
try
{
Directory.CreateDirectory("H:\\" + USER_NAME + " Backups\\" + DATE);
}
catch (Exception DateEx)
{
ShowError("Error", DateEx.ToString());
}
}
#endregion
}
/*-----------------------------------------------
* Event : CalculateSize
* Purpose : Calculates the size of a given directory
* Args :
* DirectoryInfo (object)
*
* Returns : Long
* Author : Brendan Scarvell
* Date : 03/02/08
* History :
* -----------------------------------------------
* 03/02/08 Created
-----------------------------------------------*/
public long CalculateSize(DirectoryInfo d)
{
FileInfo[] files;
files = d.GetFiles("*");
long UnFormatedSize = 0L; // need to define this variable
foreach (FileInfo file in files)
{
UnFormatedSize += file.Length; // no need for any conversions here
}
DirectoryInfo[] dirs = d.GetDirectories("*");
foreach (DirectoryInfo dir in dirs)
{
UnFormatedSize += CalculateSize(dir); // need to add to UnFormatedSize
}
return UnFormatedSize;
}
private void kryptonButton1_Click(object sender, EventArgs e)
{
Application.Exit();
}
/*-----------------------------------------------
* Event : GetUnit
* Purpose : Convert a value into a value
* Args :
* sender (object)
* e (EventArgs)
* Returns : Null
* Author : Brendan Scarvell
* Date : 03/02/08
* History :
* -----------------------------------------------
* 03/02/08 Created
-----------------------------------------------*/
private void GetUnit(ref string Size)
{
string[] units = new string[9] { "Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
double loop = Convert.ToDouble(Size);
int UnitPos = 0;
try
{
if (loop >= 1024)
{
while (loop >= 1)
{
if ((loop / 1024) >= 1)
{
loop = loop / 1024;
UnitPos++;
}
else
{
break;
}
}
}
Size = loop.ToString("F1") + " " + units[UnitPos];
}
catch (Exception cv)
{
MessageBox.Show(cv.ToString());
}
}
private void Form1_Load(object sender, EventArgs e)
{
#region # StartUp Checks
bool StartThreads = true;
// Check that all directories and paths exist
if (!Directory.Exists("H:\\"))
{
ShowError("Error", "Home Drive doesn't exist. Please contact the InfoService Center to have this resolved");
StartThreads = false;
}
if (!Directory.Exists("H:\\" + USER_NAME))
{
try
{
Directory.CreateDirectory("H:\\" + USER_NAME);
}
catch (Exception ex)
{
StartThreads = false;
ShowError("Error", ex.ToString());
}
}
#endregion
if (StartThreads)
{
Thread t = new Thread(HDrive);
t.Start();
Thread r = new Thread(Restore);
r.Start();
}
#region # Backup Methods
/** Load Backup methods **/
ToolStripMenuItem backUpDesktopMenu = new ToolStripMenuItem();
ToolStripMenuItem backUpFavsMenu = new ToolStripMenuItem();
ToolStripMenuItem backUpMacrosMenu = new ToolStripMenuItem();
ToolStripSeparator childSeperator = new ToolStripSeparator();
ToolStripMenuItem backUpAllMenu = new ToolStripMenuItem();
backUpDesktopMenu.Text = "Desktop";
backUpDesktopMenu.Image = global::Backup.Properties.Resources.monitor;
backUpDesktopMenu.Click += new EventHandler(this.BackupDesktop_Click);
backUpFavsMenu.Text = "Favorites";
backUpFavsMenu.Image = global::Backup.Properties.Resources.world;
backUpFavsMenu.Click += new EventHandler(this.BackupFavs_Click);
backUpMacrosMenu.Text = "Macros";
backUpMacrosMenu.Image = global::Backup.Properties.Resources.script_code;
backUpMacrosMenu.Click += new EventHandler(this.BackupMacros_Click);
backUpAllMenu.Text = "Everything";
backUpAllMenu.Image = global::Backup.Properties.Resources.tick;
backUpAllMenu.Click += new EventHandler(this.BackupAll_Click);
cmBackup.Items.AddRange(new ToolStripItem[] { backUpDesktopMenu, backUpFavsMenu, backUpMacrosMenu, childSeperator, backUpAllMenu });
#endregion
}
private void DesktopMenu_Click(object sender, System.EventArgs e)
{
ContextMenu x = (ContextMenu) sender;
bool msgbox;
DialogResult Restore = MessageBox.Show("Are you sure you wish to restore your Desktop Icons from '" + x.Date.ToString() + "'?", "Restore", MessageBoxButtons.YesNo);
if (Restore == DialogResult.Yes)
{
msgbox = RestoreRecursiveFiles(new DirectoryInfo(UserDirs[3, 1] + "\\" + x.Date.ToString() + "\\Desktop\\"), UserDirs[1,1],true,"*");
if (msgbox) MessageBox.Show("Desktop Icons successfully restored");
}
}
private void AllMenu_Click(object sender, System.EventArgs e)
{
ContextMenu x = (ContextMenu)sender;
DialogResult Restore = MessageBox.Show("Are you sure you wish to restore your Desktop Icons from '" + x.Date.ToString() + "'?", "Restore", MessageBoxButtons.YesNo);
if (Restore == DialogResult.Yes)
{
MessageBox.Show("Yes");
}
else
{
MessageBox.Show("no...");
}
}
private void FavsMenu_Click(object sender, System.EventArgs e)
{
ContextMenu x = (ContextMenu)sender;
bool msgbox;
DialogResult Restore = MessageBox.Show("Are you sure you wish to restore your Internet Favorites from '" + x.Date.ToString() + "'?", "Restore", MessageBoxButtons.YesNo);
if (Restore == DialogResult.Yes)
{
msgbox = RestoreRecursiveFiles(new DirectoryInfo(UserDirs[3, 1] + "\\" + x.Date.ToString() + "\\Favorites\\"), UserDirs[0,1],true,"*");
if (msgbox) MessageBox.Show("Internet Favorites restored successfully");
}
}
private void MacrosMenu_Click(object sender, System.EventArgs e)
{
ContextMenu x = (ContextMenu)sender;
bool msgbox;
DialogResult Restore = MessageBox.Show("Are you sure you wish to restore your Macros from '" + x.Date.ToString() + "'?", "Restore", MessageBoxButtons.YesNo);
if (Restore == DialogResult.Yes)
{
msgbox = RestoreRecursiveFiles(new DirectoryInfo(UserDirs[3, 1] + "\\" + x.Date.ToString() + "\\Favorites\\"), UserDirs[0, 1], true, "*");
if (msgbox) MessageBox.Show("Macros restore successfully");
}
}
/** Restore **/
private void Restore()
{
ContextMenuStrip cmRestore = new ContextMenuStrip();
cmdRestore.ContextMenuStrip = cmRestore;
DirectoryInfo R = new DirectoryInfo(UserDirs[3,1]);
int j = 0; // Used to count how many entries there are
try
{
foreach (DirectoryInfo d in R.GetDirectories("*.*"))
{
ToolStripMenuItem parentmnu = new ToolStripMenuItem();
ContextMenu childDesktop = new ContextMenu();
ContextMenu childFavs = new ContextMenu();
ContextMenu childMacros = new ContextMenu();
ToolStripSeparator childSeperator = new ToolStripSeparator();
ContextMenu childAll = new ContextMenu();
bool DisableAll = false; // Set as true if one or more back up methods are missing
// parent Item
parentmnu.Text = d.Name.ToString();
parentmnu.Image = global::Backup.Properties.Resources.folder;
// Child Items
childDesktop.Text = "Desktop";
childDesktop.Image = global::Backup.Properties.Resources.monitor;
childDesktop.Date = parentmnu.Text;
childDesktop.Click += new EventHandler(this.DesktopMenu_Click);
if (!Directory.Exists(UserDirs[3, 1] + "\\" + parentmnu.Text + "\\Desktop"))
{
childDesktop.Enabled = false;
DisableAll = true;
}
childFavs.Text = "Favorites";
childFavs.Date = parentmnu.Text;
childFavs.Image = global::Backup.Properties.Resources.world;
childFavs.Click += new EventHandler(this.FavsMenu_Click);
if (!Directory.Exists(UserDirs[3, 1] + "\\" + parentmnu.Text + "\\Favorites"))
{
childFavs.Enabled = false;
DisableAll = true;
}
childMacros.Text = "Macros";
childMacros.Date = parentmnu.Text;
childMacros.Image = global::Backup.Properties.Resources.script_code;
childMacros.Click += new EventHandler(this.MacrosMenu_Click);
if (!Directory.Exists(UserDirs[3, 1] + "\\" + parentmnu.Text + "\\Macros"))
{
childMacros.Enabled = false;
DisableAll = true;
}
childAll.Text = "All";
childAll.Image = global::Backup.Properties.Resources.tick;
childAll.Click += new EventHandler(this.AllMenu_Click);
if (DisableAll) childAll.Enabled = false;
parentmnu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { childDesktop, childFavs, childMacros, childSeperator, childAll });
cmRestore.Items.AddRange(new ToolStripItem[] { parentmnu });
j++;
}
if (j == 0)
{
ToolStripMenuItem parentmnu = new ToolStripMenuItem();
parentmnu.Text = "No backups created";
parentmnu.Image = global::Backup.Properties.Resources.error;
cmRestore.Items.AddRange(new ToolStripItem[] { parentmnu });
}
}
catch (Exception ex)
{
ShowError("FATAL ERROR", ex.Message.ToString());
}
}
private void bwRestore_DoWork(object sender, DoWorkEventArgs e)
{
}
private void HDrive()
{
string HomeDirSpace = CalculateSize(new DirectoryInfo("H:\\")).ToString(); // Store Home drive space into a variable.
GetUnit(ref HomeDirSpace);
double percentage = (Convert.ToDouble(CalculateSize(new DirectoryInfo("H:\\"))) / 209715200) * 100;
//MessageBox.Show(percentage.ToString());
khpercentage.Values.Description = percentage.ToString("F0") + " %";
khpercentage.Width = Convert.ToInt32((percentage / 100) * 400);
lblSpace.Visible = false;
}
private void bwHdrive_DoWork(object sender, DoWorkEventArgs e)
{
string HomeDirSpace = CalculateSize(new DirectoryInfo("H:\\")).ToString(); // Store Home drive space into a variable.
lbHSpace.Text = "Home Drive Space";
GetUnit(ref HomeDirSpace);
double percentage = (Convert.ToDouble(CalculateSize(new DirectoryInfo("H:\\"))) / 209715200) * 100;
khpercentage.Values.Description = percentage.ToString("F0") + " %";
khpercentage.Width = ((int)percentage / 100) * 400;
lblSpace.Visible = false;
}
private void tmrFlash_Tick(object sender, EventArgs e)
{
int count = 0;
if (lblWarning.Visible)
{
lblWarning.Visible = false;
count++;
}
else if (count == 3)
{
lblWarning.Visible = true;
this.Enabled = false;
}
else
{
lblWarning.Visible = true;
}
}
/*-----------------------------------------------
* Event : ButtonDown
* Purpose : Trigger a mouse move event to move form around
* Args :
* sender (object)
* e (EventArgs)
* Returns : Null
* Author : Brendan Scarvell
* Date : 17 April 2008
* History :
* -----------------------------------------------
* 17/04/2008 Created
-----------------------------------------------*/
private void ButtonDown(object sender, MouseEventArgs mea)
{
diff_x = Form.MousePosition.X - Form.ActiveForm.Location.X;
diff_y = Form.MousePosition.Y - Form.ActiveForm.Location.Y;
this.hdrTitleBar.MouseMove += new MouseEventHandler(Form_MouseMove);
}
/*-----------------------------------------------
* Event : ButtonDown
* Purpose : Trigger a mouse move event to move form around
* Args :
* sender (object)
* e (EventArgs)
* Returns : Null
* Author : Brendan Scarvell
* Date : 17 April 2008
* History :
* -----------------------------------------------
* 17/04/2008 Created
-----------------------------------------------*/
private void Form_MouseMove(object sender, MouseEventArgs e)
{
//as the mouse point moves the form moves with it
Point p = new Point(MousePosition.X - diff_x, MousePosition.Y - diff_y);
Form.ActiveForm.Location = p;
//creates the MouseUp eventhandler
this.hdrTitleBar.MouseUp += new System.Windows.Forms.MouseEventHandler(Form_MouseUp);
}
/*-----------------------------------------------
* Event : ButtonDown
* Purpose : Trigger a mouse move event to move form around
* Args :
* sender (object)
* e (EventArgs)
* Returns : Null
* Author : Brendan Scarvell
* Date : 17 April 2008
* History :
* -----------------------------------------------
* 17/04/2008 Created
-----------------------------------------------*/
private void Form_MouseUp(object sender, MouseEventArgs e)
{
//on MouseUp event, remove the MouseMove eventhandler
this.hdrTitleBar.MouseMove -= new MouseEventHandler(Form_MouseMove);
}
// Error procedure
private void ShowError(string title, string body)
{
// Move the form size to display error box
frmMain.ActiveForm.Size = new System.Drawing.Size(frmMain.ActiveForm.Size.Width, frmMain.ActiveForm.Size.Height + 80);
pnlMenu.Location = new System.Drawing.Point(11, (pnlMenu.Location.Y + 80));
pnlSpace.Location = new System.Drawing.Point(pnlSpace.Location.X, (pnlSpace.Location.Y + 80));
//pnlFiles.Location = new System.Drawing.Point(pnlFiles.Location.X, (pnlFiles.Location.Y + 80));
cmdQuit.Location = new System.Drawing.Point(cmdQuit.Location.X, (cmdQuit.Location.Y + 80));
kpError.Visible = true;
lblWarning.Text = title;
lblMessage.Text = body;
}
private void ClearError()
{
frmMain.ActiveForm.Size = new System.Drawing.Size(frmMain.ActiveForm.Size.Width, frmMain.ActiveForm.Size.Height - 80);
pnlMenu.Location = new System.Drawing.Point(11, (pnlMenu.Location.Y - 80));
pnlSpace.Location = new System.Drawing.Point(pnlSpace.Location.X, (pnlSpace.Location.Y - 80));
//pnlFiles.Location = new System.Drawing.Point(pnlFiles.Location.X, (pnlFiles.Location.Y - 80));
cmdQuit.Location = new System.Drawing.Point(cmdQuit.Location.X, (cmdQuit.Location.Y - 80));
kpError.Visible = false; ;
lblWarning.Text = "";
lblMessage.Text = "";
}
private void kryptonButton2_Click_1(object sender, EventArgs e)
{
ClearError();
}
private void cmdBackup_Click(object sender, EventArgs e)
{
DialogResult a = MessageBox.Show("Are you sure you wish to back your Desktop, Favourites and Macros?", "Back Up", MessageBoxButtons.YesNo);
if (a == DialogResult.Yes)
{
MessageBox.Show("Perform backup");
}
else
{
MessageBox.Show("Abort");
}
}
private void asdf_Click(object sender, EventArgs e)
{
MessageBox.Show("Testorama");
}
private void cmdRefresh_Click_1(object sender, EventArgs e)
{
lblSpace.Visible = true;
Thread t = new Thread(HDrive);
t.Start();
}
private void kcmBackup_Opening(object sender, CancelEventArgs e)
{
}
private void BackupDesktop_Click(object sender, EventArgs e)
{
DialogResult dr;
bool msgbox;
dr = MessageBox.Show("Are you sure you wish to backup your desktop icons?", "Desktop Backup", MessageBoxButtons.YesNo);
if (dr == DialogResult.Yes)
{
msgbox = CopyRecursiveFiles(new DirectoryInfo(UserDirs[1, 1]), UserDirs[3,1] + DATE + "\\" + UserDirs[1,0], false, "*");
if (msgbox) MessageBox.Show("Desktop Backup Completed Successfully");
}
}
private void BackupFavs_Click(object sender, EventArgs e)
{
DialogResult dr;
bool msgbox;
dr = MessageBox.Show("Are you sure you wish to backup your favorites?", "Desktop Backup", MessageBoxButtons.YesNo);
if (dr == DialogResult.Yes)
{
msgbox = CopyRecursiveFiles(new DirectoryInfo(UserDirs[0, 1]), UserDirs[3, 1] + DATE + "\\" + UserDirs[0, 0], false, "*");
if (msgbox) MessageBox.Show("Favorites Backup Completed Successfully");
}
}
private void BackupMacros_Click(object sender, EventArgs e)
{
DialogResult dr;
bool msgbox;
dr = MessageBox.Show("Are you sure you wish to backup your macros?", "Desktop Backup", MessageBoxButtons.YesNo);
if (dr == DialogResult.Yes)
{
msgbox = CopyRecursiveFiles(new DirectoryInfo(UserDirs[2, 1]), UserDirs[3, 1] + DATE + "\\" + UserDirs[2, 0], false, "*");
if (msgbox) MessageBox.Show("Macros Backup Completed Successfully");
}
}
private void BackupAll_Click(object sender, EventArgs e)
{
DialogResult dr;
bool msgbox,msgbox2,msgbox3;
dr = MessageBox.Show("Are you sure you wish to perform a full backup? \n\n WARNING: This could be a time consuming process", "Backup", MessageBoxButtons.YesNo);
if (dr == DialogResult.Yes)
{
msgbox = CopyRecursiveFiles(new DirectoryInfo(UserDirs[0, 1]), UserDirs[3, 1] + DATE + "\\" + UserDirs[0, 0], false, "*");
msgbox2 = CopyRecursiveFiles(new DirectoryInfo(UserDirs[1, 1]), UserDirs[3, 1] + DATE + "\\" + UserDirs[1, 0], false, "*");
msgbox3 = CopyRecursiveFiles(new DirectoryInfo(UserDirs[2, 1]), UserDirs[3, 1] + DATE + "\\" + UserDirs[2, 0], false, "*");
if (msgbox && msgbox2 && msgbox3) MessageBox.Show("Backup Completed Successfully");
}
}
private void tmrRestore_Tick(object sender, EventArgs e)
{
Thread r = new Thread(Restore);
r.Start();
}
}
}
Comment