Tye is a tool that makes developing, testing, and deploying microservices and distributed applications easier. Project Tye includes a local orchestrator to make developing microservices easier and the ability to deploy microservices to Kubernetes with min
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

39 lines
1.3 KiB

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.IO;
namespace Microsoft.Tye
{
internal static class DirectoryExtensions
{
// Calling Directory.Delete causes an exception for .git folders:
// System.UnauthorizedAccessException : Access to the path '17a475ecca365c678e907bd4c73e4c65b341c6' is denied.
public static void DeleteDirectory(string directoryPath)
{
foreach (var subDirectoryPath in Directory.EnumerateDirectories(directoryPath))
{
DeleteDirectory(subDirectoryPath);
}
try
{
foreach (var filePath in Directory.EnumerateFiles(directoryPath))
{
var fileInfo = new FileInfo(filePath)
{
Attributes = FileAttributes.Normal
};
fileInfo.Delete();
}
Directory.Delete(directoryPath);
}
catch (Exception e)
{
Console.WriteLine($@"Failed to delete directory {directoryPath}: {e.Message}");
}
}
}
}