private async Task DeleteContents() { var files = ScanHelper.GetFiles(SourceDir, keywords: Keywords); var subDirectories = ScanHelper.GetSubDirectories(SourceDir, excludeEmpty: ExcludeEmptyDirectories); if (Frequency == FrequencyEnum.AfterDays) { files = ScanHelper.FilterFilesByAge(DayLimit, files); subDirectories = ScanHelper.FilterDirectoriesByAge(DayLimit, subDirectories); } ScanHelper.DeleteFiles(files); ScanHelper.DeleteDirectories(subDirectories); }
public async void ExecuteAction() { try { FileList = ScanHelper.GetFiles(SourceDir, keywords: Keywords, daysThreshold: DayLimit); switch (Action) { case ActionEnum.Move: await Task.Run(MoveFiles); break; case ActionEnum.Copy: await Task.Run(CopyFiles); break; case ActionEnum.Delete: await Task.Run(DeleteContents); break; case ActionEnum.DropboxCleanup: await Task.Run(CleanupDropbox); break; case ActionEnum.CompressContents: await Task.Run(CompressContents); break; case ActionEnum.PromptAction: PromptAction(); break; default: break; } Counter = 0; MainWindow.Instance.LogActivity(rule: this, success: true, message: "Rule executed successfully"); } catch (Exception ex) { MainWindow.Instance.HandleError(exception: ex, rule: this); } }