1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-28 13:15:12 +01:00
bitwarden-server/test/Core.Test/TempDirectory.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
763 B
C#
Raw Normal View History

namespace Bit.Core.Test;
2022-08-29 22:06:55 +02:00
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)
2022-08-29 22:06:55 +02:00
{
if (disposing)
{
2022-08-29 22:06:55 +02:00
try
{
System.IO.Directory.Delete(Directory, true);
}
catch { }
}
}
# endregion
}