예제 #1
0
        /// <summary>
        /// folder comparison method
        /// </summary>
        /// <see cref=" DelDir.Add()"/>
        /// <see cref="DeleteDir"()/>
        /// <param name="import">parameter for working with the class ImportSinchronizaer</param>
        /// <param name="export">parameter for working with the class ExportSinhronizaer</param>
        public static void TestDirectory(ImportSinchronizaer import, ExportSinhronizaer export)
        {
            List <string> DelDir = new List <string>();                                               //list for delete folders
            bool          Add    = false;

            foreach (var dirEx in export.Dir)                                                       //open export list dirs
            {
                Add = false;
                string WayEx = dirEx.Remove((int)Nums.Zero, export.Root.Length);
                foreach (var dirIm in import.Dir)                                                    //open import list dirs
                {
                    string WayIm = dirIm.Remove((int)Nums.Zero, import.Root.Length);
                    if (WayEx == WayIm)                                                             //if way export==way import
                    {
                        Add = true;
                        break;
                    }
                }
                if (!Add)
                {
                    DelDir.Add(dirEx);                                                              //add in list delete folders
                }
            }
            DeleteDir(DelDir);                                                                     //call delete dir
        }
예제 #2
0
 /// <summary>
 /// file comparison method
 /// </summary>
 /// <see cref="TestFileExport()"/>
 /// <see cref="CopyFile"/>
 /// <see cref="export.AddNewFile()"/>
 /// <param name="import">parameter for working with the class ImportSinchronizaer</param>
 /// <param name="export">parameter for working with the class ExportSinhronizaer</param>
 static public void TestFile(ImportSinchronizaer import, ExportSinhronizaer export)
 {
     foreach (var fileIm in import.File)                                                                                   //open file int import for comparison
     {
         FileStream fileImpor = new FileStream(fileIm, FileMode.Open, FileAccess.Read);                                    //open file
         string     Way       = String.Format("{0}\\{1}", export.Root, fileIm.Remove((int)Nums.Zero, import.Root.Length)); //create way for comparison
         bool       flag      = true;                                                                                      //flag for copy file or not
         if (export.Files.Count > (int)Nums.Zero)
         {
             flag = TestFileExport(export, fileImpor, fileIm, Way);                                            //call method export object
         }
         if (flag)
         {
             CopyFile(fileImpor, Way);                                                                        //call method for copy
             export.AddNewFile(Way);                                                                          //call method for add new dir
         }
     }
 }