using System.IO; using System.Threading; using System.Threading.Tasks; namespace Artemis.Core { /// /// Represents a plugin prerequisite action that deletes a file /// public class DeleteFileAction : PluginPrerequisiteAction { /// /// Creates a new instance of a copy folder action /// /// The name of the action /// The target folder to delete recursively public DeleteFileAction(string name, string target) : base(name) { Target = target; ProgressIndeterminate = true; } /// /// Gets or sets the target directory /// public string Target { get; } /// public override async Task Execute(CancellationToken cancellationToken) { ShowProgressBar = true; Status = $"Removing {Target}"; await Task.Run(() => { if (File.Exists(Target)) File.Delete(Target); }, cancellationToken); ShowProgressBar = false; Status = $"Removed {Target}"; } } }