protected void MoveCacheBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            var worker      = (BackgroundWorker)sender;
            var workerModel = (MoveCacheBackgroundWorkerModel)e.Argument;

            IsMovingFolder = true;
            worker.ReportProgress(0);

            try
            {
                long handledSize = 0;
                //1.获取所有待转移的缓存列表
                var currentOperationDetail = "获取所有待转移的文件..";
                worker.ReportProgress(0, new ProgressChangedContent()
                {
                    OperationDetail = currentOperationDetail
                });
                var allCacheFiles = FolderUtil.GetAllFiles(workerModel.DeskTopFolder, out long usertotalSize);
                MoveCacheFiles(allCacheFiles, ref handledSize, workerModel, usertotalSize, worker);
            }
            catch (Exception exception)
            {
                RestoreCacheFilesToPreviousPath(workerModel);
                LogHelper.Error(exception.Message);
                throw;
            }

            //返回执行结果
            e.Result = workerModel;
        }
Beispiel #2
0
        private static List <string> GetAllPictures()
        {
            var list                 = new List <string>();
            var baseDirectory        = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
            var memoryPicturesFolder = Path.Combine(baseDirectory, @"Resources\MemoryPictures");

            if (Directory.Exists(memoryPicturesFolder))
            {
                var allFiles = FolderUtil.GetAllFiles(memoryPicturesFolder);
                list.AddRange(allFiles);
            }

            return(list);
        }
        /// <summary>
        /// 一致
        /// </summary>
        /// <returns></returns>
        public static List <ColorPictureInfo> GetConsistentPictures()
        {
            var list                 = new List <ColorPictureInfo>();
            var baseDirectory        = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
            var memoryPicturesFolder = Path.Combine(baseDirectory, @"Resources\MemoryPictures\一致");

            if (Directory.Exists(memoryPicturesFolder))
            {
                var allFiles = FolderUtil.GetAllFiles(memoryPicturesFolder);
                list.AddRange(allFiles.Select(i => GetPictureInfo(i)));
            }

            if (list.Count < 1)
            {
                throw new InvalidOperationException($"图片配置数量小于{0}张!");
            }
            return(list);
        }