Пример #1
0
        public static void doBackUp(BackUp obj, NotifyIcon notifyIcon_Main, List <BackUp> backUpList, string saveFile, DataGridView dtgrdvDisplay)
        {
            try
            {
                obj.objInit();
                obj.pathToListAdd(obj.pathTo);

                DirectoryCopy(obj.pathFrom, obj.pathToList[obj.pathToList.Count - 1], true);

                notifyIcon_Main.BalloonTipTitle = "New Backup Created";
                notifyIcon_Main.BalloonTipText  = obj.descr +
                                                  Environment.NewLine + "From:" + obj.pathFrom +
                                                  Environment.NewLine + "To:" + obj.pathTo;
                notifyIcon_Main.ShowBalloonTip(500);


                obj.historyDateList.Add(DateTime.Now);
                obj.historyList.Add(new BackUpHistory(DateTime.Now, true, obj.size, obj.files, obj.folders));


                obj.displayInit();

                SaveBackUp(backUpList, saveFile);
                gridRefresh(backUpList, dtgrdvDisplay);
            }
            catch
            {
            }
        }
Пример #2
0
        private void doBackUp(BackUp obj)
        {
            string dirPath = obj.pathTo + "/" + obj.descr + "_Backup_" +
                             DateTime.Now.Day + "-" +
                             DateTime.Now.Month + "-" +
                             DateTime.Now.Year + "_" +
                             DateTime.Now.Hour + "_" +
                             DateTime.Now.Minute + "_" +
                             DateTime.Now.Second;

            try
            {
                Tools.DirectoryCopy(obj.pathFrom, dirPath, true);

                notifyIcon_Main.BalloonTipTitle = "New Backup Created";
                notifyIcon_Main.BalloonTipText  = obj.descr +
                                                  Environment.NewLine + "From:" + obj.pathFrom +
                                                  Environment.NewLine + "To:" + obj.pathTo;
                notifyIcon_Main.ShowBalloonTip(500);
                DirectoryInfo di = new DirectoryInfo(obj.pathFrom);
                obj.size  = di.EnumerateFiles("*", SearchOption.AllDirectories).Sum(fi => fi.Length);
                obj.size /= 1024;
                obj.size /= 1024;
                obj.size  = Math.Round(obj.size, 2);
                obj.files = Directory.GetFiles(obj.pathFrom, "*.*", SearchOption.AllDirectories).Length;
                obj.historyDateList.Add(obj.Date);
                obj.folders = di.GetDirectories().Length;
                obj.historyList.Add(new BackUpHistory(obj.Date, true, obj.size, obj.files, obj.folders));
                BackUp.AddExtraTime(obj);
                obj.displayInit();

                gridRefresh();
                SaveBackUp();
            }
            catch
            {
            }
        }