Exemple #1
0
        public event ErrorDelegate ErrorEvent;                          // If this is raised, then you have a problem

        /// <summary>
        /// Initializes a new instance of the FolderSync class which uses FolderDiff to
        /// synchronize two folders. Call Sync() to start synchronizing.
        /// </summary>
        /// <param name="folderName1">First folder name</param>
        /// <param name="folderName2">Second folder name</param>
        /// <param name="defMissingInFolder1">Default action for files which are missing in the first folder.</param>
        /// <param name="defMissingInFolder2">Default action for files which are missing in the second folder.</param>
        /// <param name="defDifferentFiles">Default action for files which have different sizes.</param>
        public FolderSync(string folderName1, string folderName2,
                          FileActions defMissingInFolder1,
                          FileActions defMissingInFolder2,
                          FileActions defDifferentFiles)
        {
            if (defMissingInFolder1 == FileActions.OverwriteNewer |
                defMissingInFolder1 == FileActions.OverwriteOlder |
                defMissingInFolder1 == FileActions.Write1to2 |                          // These choices are not valid
                defMissingInFolder1 == FileActions.Write2to1)
            {
                this.initialized = false;
                if (this.ErrorEvent != null)
                {
                    this.ErrorEvent(new ArgumentException("defaultActionForMissingFiles1 is not correct"), null);
                }
            }
            if (defMissingInFolder2 == FileActions.OverwriteNewer |
                defMissingInFolder2 == FileActions.OverwriteOlder |
                defMissingInFolder2 == FileActions.Write1to2 |                          // These choices are not valid
                defMissingInFolder2 == FileActions.Write2to1)
            {
                this.initialized = false;
                if (this.ErrorEvent != null)
                {
                    this.ErrorEvent(new ArgumentException("defaultActionForMissingFiles2 is not correct"), null);
                }
            }

            if (defDifferentFiles == FileActions.Copy)
            {
                this.initialized = false;
                if (this.ErrorEvent != null)
                {
                    this.ErrorEvent(new ArgumentException("defaultActionForDifferentFiles is not correct"), null);
                }
            }

            this.defMissing1        = defMissingInFolder1;
            this.defMissing2        = defMissingInFolder2;
            this.defSize            = defDifferentFiles;
            this.folderName1        = folderName1;
            this.folderName2        = folderName2;
            this.diff               = new FolderDiff(this.folderName1, this.folderName2);
            this.diff.CompareEvent += new CompareDelegate(Compared);
        }
Exemple #2
0
		public event ErrorDelegate ErrorEvent;			// If this is raised, then you have a problem

		/// <summary>
		/// Initializes a new instance of the FolderSync class which uses FolderDiff to
		/// synchronize two folders. Call Sync() to start synchronizing.
		/// </summary>
		/// <param name="folderName1">First folder name</param>
		/// <param name="folderName2">Second folder name</param>
		/// <param name="defMissingInFolder1">Default action for files which are missing in the first folder.</param>
		/// <param name="defMissingInFolder2">Default action for files which are missing in the second folder.</param>
		/// <param name="defDifferentFiles">Default action for files which have different sizes.</param>
		public FolderSync(string folderName1, string folderName2, 
			FileActions defMissingInFolder1, 
			FileActions defMissingInFolder2,
			FileActions defDifferentFiles)
		{
			if (defMissingInFolder1 == FileActions.OverwriteNewer |
				defMissingInFolder1 == FileActions.OverwriteOlder |
				defMissingInFolder1 == FileActions.Write1to2 |		// These choices are not valid
				defMissingInFolder1 == FileActions.Write2to1)
			{
				this.initialized = false;
				if (this.ErrorEvent != null)
					this.ErrorEvent(new ArgumentException("defaultActionForMissingFiles1 is not correct"), null);
			}
			if (defMissingInFolder2 == FileActions.OverwriteNewer |
				defMissingInFolder2 == FileActions.OverwriteOlder |
				defMissingInFolder2 == FileActions.Write1to2 |		// These choices are not valid
				defMissingInFolder2 == FileActions.Write2to1)
			{
				this.initialized = false;
				if (this.ErrorEvent != null)
					this.ErrorEvent(new ArgumentException("defaultActionForMissingFiles2 is not correct"), null);
			}

			if (defDifferentFiles == FileActions.Copy)
			{
				this.initialized = false;
				if (this.ErrorEvent != null)
					this.ErrorEvent(new ArgumentException("defaultActionForDifferentFiles is not correct"), null);
			}

			this.defMissing1 = defMissingInFolder1;
			this.defMissing2 = defMissingInFolder2;
			this.defSize = defDifferentFiles;
			this.folderName1 = folderName1;
			this.folderName2 = folderName2;
			this.diff = new FolderDiff(this.folderName1, this.folderName2);
			this.diff.CompareEvent += new CompareDelegate(Compared);
		}