1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00
Robert 0cfddcbbaf Plugin prerequisites - Added UI for installing/removing prerequisites
Plugin settings - Added button to reload plugin from disk
Confirm dialogs - Made cancel text optional so you can hide the button
2021-04-28 00:33:56 +02:00

44 lines
1.3 KiB
C#

using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace Artemis.Core
{
/// <summary>
/// Represents a plugin prerequisite action that deletes a file
/// </summary>
public class DeleteFileAction : PluginPrerequisiteAction
{
/// <summary>
/// Creates a new instance of a copy folder action
/// </summary>
/// <param name="name">The name of the action</param>
/// <param name="target">The target folder to delete recursively</param>
public DeleteFileAction(string name, string target) : base(name)
{
Target = target;
ProgressIndeterminate = true;
}
/// <summary>
/// Gets or sets the target directory
/// </summary>
public string Target { get; }
/// <inheritdoc />
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}";
}
}
}