[DATFromDir] Add async delete

This commit is contained in:
Matt Nadareski
2016-09-22 09:42:45 -07:00
parent 57f6d361f7
commit 656ac774ab
2 changed files with 26 additions and 28 deletions

View File

@@ -11,6 +11,7 @@ using System.IO.Compression;
using System.Linq;
using System.Security.Cryptography;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace SabreTools.Helper
{
@@ -1237,6 +1238,29 @@ namespace SabreTools.Helper
}
}
/// <summary>
/// Delete a file asynchronously
/// </summary>
/// <param name="filename">Name of the file to be deleted</param>
public async static void DeleteFile(string filename)
{
FileInfo fi = new FileInfo(filename);
await Task.Factory.StartNew(() =>
{
while (fi.Exists)
{
try
{
fi.Delete();
}
catch
{
}
}
});
}
#endregion
}
}