protected override void OnApply(PageApplyEventArgs e) { // Clean up the path CachePath = CachePath.Replace("/", "\\"); if (string.IsNullOrEmpty(CachePath)) { e.ApplyBehavior = ApplyKind.Cancel; } else { base.OnApply(e); } }
// Cleaning // Foreach all cache directories private void CacheDirsDeleting(string[] TargetPaths, bool ConfirmClean) { // Foreach all subfolders foreach (string CachePath in TargetPaths) { string ReplacedString = CachePath.Replace(@"\\", @"\"); string[] CuttedString = ReplacedString.Split('\\'); // If dir name length = 36 if (CuttedString[CuttedString.Length - 1].Length == 36) { try { double TempCacheSize = 0L; string[] AllCacheFiles = Directory.GetFiles(CachePath, "*.*", SearchOption.AllDirectories); foreach (string FileName in AllCacheFiles) { File.SetAttributes(FileName, FileAttributes.Normal); FileInfo Info = new FileInfo(FileName); TempCacheSize += Info.Length; } if (ConfirmClean) { Directory.Delete(CachePath, true); } // in a case of error, current cache size will be deleted CacheSize += TempCacheSize; } catch { //MessageBox.Show(ex.ToString()); if (CacheErrorCount != 0) { MessageBox.Show("Не все папки с кэшем особождены от процессов 1С.\n\nПопробуйте:\n• запустить очистку в агрессивном режиме\n• завершить все процессы 1С через диспетчер задач\n• запустить очистку после перезагрузки ПК.\n\nПроизойдёт очситка только незанятых папок", "Очистка не будет полной", MessageBoxButton.OK, MessageBoxImage.Exclamation); } CacheErrorCount++; // Break return; } } } }