C# Console App – Microsoft Sync Framework

I’ve written a simple C# Console Application that will synchronize two folders or drives on your computer.

I am eventually going to build a home server to house all of my family photos, music, movies, and other media. However, I am not in the market for purchasing any server software or hardware at this time. I wanted a simple way to backup all my data. I understand there are many different options already available for backing up data, but I didn’t want to install some third party app that comes with a bunch of things I don’t need. I’ve decided to do this using Microsoft’s Sync Framework.

Example 1:

D:\ Drive has 4 Documents:

E:\ Drive has 0 Documents:

2018-04-09 16_10_46-Movies _ TV

This would be the end result:

2018-04-09 16_14_57-zync - Microsoft Visual Studio

Example 2:

My plan is to add new files to the D:\ drive and then regularly copy that drives entire contents to the B:\ drive. My old method was having my Operating System (OS) and all my files on one drive, and then manually backing up all my files onto an external hard drive. I purchased a new 1TB Hard Disk Drive (HDD) and a 250GB Solid State Drive (SDD). I moved all of my files to the new HDD and then removed them all from the existing HDD. I then moved the OS to the SSD, and then wiped the existing HDD. At this point I have my OS on the SSD, all of my files on the new HDD, and an empty existing HDD. After renaming the drives that that the letters are how I want them, I’m ready to move all my data.

Launching the program will just open a console window, and tell you that it is syncing D:\ and B:\. I have these values hard-coded so I will never accidentally sync the wrong drives or lose any data. I originally had the program ask the user to enter in each path manually, but there is way too much room for error there.

2018-04-24 21_31_49-zync

When it is complete, it will tell you that it has finished and tell you how long it took:

2018-04-24 21_33_31-zync

This example was syncing about 200GB worth of files. 55 seconds is a reasonable amount of time in my opinion. If you were to select all files in the D:\ drive, and then move them all to the B:\ drive manually, it would take significantly longer.

Implementation:

Once you have downloaded the SDK from this location, you are free to use the framework in your C# application. Here is an example of what my source code looks like:

2018-04-27 13_45_15-zync - Microsoft Visual Studio

 

I hope someone can find this useful. Thanks for reading!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s