Katteker/Creator/Helper/TemporaryDirectory.cs

28 lines
532 B
C#

using System;
using System.Threading;
namespace KattekerCreator.Helper
{
public class TemporaryDirectory : IDisposable
{
public string Path { get; }
public TemporaryDirectory(string path)
{
Path = path;
}
void IDisposable.Dispose()
{
try
{
Thread.Sleep(100);
System.IO.Directory.Delete(Path, true);
}
catch
{
//ignore.
}
}
}
}