Пример #1
0
 public void Copy(string fileSource, string fileDestination) //Метод копирования БД
 {
     if (ServiceClass.ChekServices(Program.controllers))
     {
         MessageBox.Show("Не все службы остановлены");
     }
     else
     {
         FileStreamSource      = new FileStream(fileSource, FileMode.Open);
         FileStreamDestination = new FileStream(fileDestination, FileMode.OpenOrCreate);
         double countEtalon = FileStreamSource.Length / 100;
         double persent     = 1;
         double count       = 0;
         while (FileStreamSource.Position < FileStreamSource.Length)
         {
             byte[] buffer = new byte[1000000];
             int    i      = FileStreamSource.Read(buffer, 0, buffer.Length);
             FileStreamDestination.Write(buffer, 0, i);
             while (persent < 100)
             {
                 count  += countEtalon;
                 persent = count * 100 / FileStreamSource.Length;
                 Program.myForm.updProgressBar(persent);
             }
         }
         FileStreamSource.Close();
         FileStreamDestination.Flush();
         FileStreamDestination.Close();
         chekMD5(fileSource, fileDestination);
     }
 }