dotnet-installer/src/Microsoft.DotNet.TestFramework/TestDirectory.cs

39 lines
981 B
C#
Raw Normal View History

// 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.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
namespace Microsoft.DotNet.TestFramework
{
public class TestDirectory
{
internal TestDirectory(string path)
{
if (string.IsNullOrEmpty(path))
{
2016-04-25 11:22:32 -07:00
throw new ArgumentException(nameof(path));
}
2016-04-25 11:22:32 -07:00
Path = path;
2016-04-25 11:22:32 -07:00
EnsureExistsAndEmpty(Path);
}
2016-04-25 11:22:32 -07:00
public string Path { get; private set; }
2016-04-25 11:22:32 -07:00
private static void EnsureExistsAndEmpty(string path)
{
if (Directory.Exists(path))
{
Directory.Delete(path, true);
}
Directory.CreateDirectory(path);
}
}
2016-04-25 11:22:32 -07:00
}