![]() If you create MultiKe圜ollection with string everytime you add an object to the collection, it will create a key from property PropA, B and C of that object and that object must have those properties. ![]() A MultiKe圜ollection class is basically a wrapper for Dictionary but the differences is, it will create the key ( string) from properties of a class. After that, passing a FolderSynchronizationScannerItem to the object AddScan method, and it will begin scanning and synchronizing both folders:įolderSynchronization _Sync = new FolderSynchronization() įolderSynchronizationScannerItem fssi = new FolderSynchronizationScannerItem() įssi.Source = " C:\users\username\desktop\Folder1" įssi.Destination = " C:\users\username\desktop\Folder2" įssi.Option = FolderSynchorizationOption.Both Īs already explained, there are 3 threads running when you call _Sync.Start, and when you call _Sync.AddScan, the current running thread will add the FolderSynchronizationScannerItem into _ScanQueue, this scanning queue will popup by Scanning Thread, and when a dequeue occurs, Scanning Thread will call Sync() method from class FolderSynchronizationScanner and it will continue working on that thread until all directories and sub directories are found and return a MultiKe圜ollection. Using the Codeįirst create the instance of the synchronization object, then start it. The third thread or Monitor Thread, is basically popping job from the queue and checking if source and destination folders both exist, if it does not exist, it will continue monitoring until it exists and when it exists, it will search for differences and push FileOperation objects to Queue. If difference is found, it will create a FileOperation object and push to Queue so that the first thread can operate, while if somehow the folders needed to be synchronized do not exist (either source or destination or both) this thread will then queue a monitor job for the third thread. The second thread, which is a Scanning thread will scan two folders, and searches for any differences. These FileOperation objects are created by the second thread and push to queue. The first thread is Syncing Thread to pop out any new FileOperation from Queue, a FileOperation is an instance of an object which has polymorphism DoOperation() method, the method will be called and do operation such as copy file from one folder to another, or creating a folder (if it does not exist). The background of this application is a class name FolderSynchronization, when started, this class will start 3 threads. This application will synchronize two folders either in both direction (copy from source to destination and destination to source) or only one direction (destination). ![]() At first, I am confused since I have lots of files needed to be backed up in the office and home computer, but sometimes I often forget whether the file in my computer is the latest or the file in the office is the latest? Sometimes I have made changes on both computers, so I need a way to synchronized the two folders!īeginning from there, I am writing this application FolderSync, the very first version 1.0. The application attached in this article is fully functional. ![]() Once available, it will start searching for differences and start the Syncing task. Note that both the folders must exist, if one or both of the folders do not exist, the application assumes that it is offline and continues monitoring until it is available. The application will then synchronize the two folders in the background. Wait for the processing window to close, then click the Hide button. Manually type source folder location, and destination location, and click Save. For user wanting to test the application without source, run the downloaded Installer and install the application, then run the application by clicking the short cut in the desktop, open the second tab, and click Add button located below.
0 Comments
Leave a Reply. |