2021-12-16 15:35:09 +01:00
|
|
|
|
using System;
|
2021-02-22 22:35:16 +01:00
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
namespace Bit.Core.Test
|
|
|
|
|
{
|
|
|
|
|
public class TempDirectory : IDisposable
|
|
|
|
|
{
|
|
|
|
|
public string Directory { get; private set; }
|
|
|
|
|
|
|
|
|
|
public TempDirectory()
|
|
|
|
|
{
|
|
|
|
|
Directory = Path.Combine(Path.GetTempPath(), $"bitwarden_{Guid.NewGuid().ToString().Replace("-", "")}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ToString() => Directory;
|
|
|
|
|
|
|
|
|
|
#region IDisposable implementation
|
|
|
|
|
~TempDirectory()
|
|
|
|
|
{
|
|
|
|
|
Dispose(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
Dispose(true);
|
|
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose(bool disposing)
|
|
|
|
|
{
|
|
|
|
|
if (disposing)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
System.IO.Directory.Delete(Directory, true);
|
|
|
|
|
}
|
|
|
|
|
catch { }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
# endregion
|
|
|
|
|
}
|
|
|
|
|
}
|