dotnet-installer/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/DisposableDirectory.cs

31 lines
751 B
C#
Raw Normal View History

2015-12-15 01:39:29 +00:00
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.IO;
namespace Microsoft.DotNet.Tools.Test.Utilities
{
public sealed class DisposableDirectory : TempDirectory, IDisposable
{
public DisposableDirectory(TempRoot root)
: base(root)
{
}
public void Dispose()
{
if (Path != null && Directory.Exists(Path))
{
try
{
Directory.Delete(Path, recursive: true);
}
catch
{
}
}
}
}
}