mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
More complex directory deletion
This commit is contained in:
parent
ac54d8d89d
commit
a3e545281e
@ -187,7 +187,24 @@ public static class AbsolutePathExtensions
|
||||
{
|
||||
if (!path.DirectoryExists()) return;
|
||||
if (dontDeleteIfNotEmpty && (path.EnumerateFiles().Any() || path.EnumerateDirectories().Any())) return;
|
||||
Directory.Delete(ToNativePath(path), true);
|
||||
|
||||
foreach (string directory in Directory.GetDirectories(path.ToString()))
|
||||
{
|
||||
DeleteDirectory(directory.ToAbsolutePath(), dontDeleteIfNotEmpty);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Directory.Delete(path.ToString(), true);
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
Directory.Delete(path.ToString(), true);
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
Directory.Delete(path.ToString(), true);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool DirectoryExists(this AbsolutePath path)
|
||||
|
@ -91,8 +91,6 @@ public class AuthorFiles
|
||||
public async Task DeleteFile(FileDefinition definition)
|
||||
{
|
||||
var folder = AuthorFilesLocation.Combine(definition.MungedName);
|
||||
foreach (var file in folder.EnumerateFiles())
|
||||
file.Delete();
|
||||
folder.DeleteDirectory();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user