Fixed runtime crash on fs.delete deleting full directory not recursively

This commit is contained in:
Alessandro Proto 2023-02-01 08:28:36 +01:00
parent c278d997ff
commit 17056b3269

View file

@ -414,6 +414,11 @@ public class FileSystem : IPlugin
var attr = File.GetAttributes(path); var attr = File.GetAttributes(path);
if (attr.HasFlag(FileAttributes.Directory)) if (attr.HasFlag(FileAttributes.Directory))
{ {
if(!recursive && Directory.GetFileSystemEntries(path).Any())
{
L.Error("directory not empty");
return 0;
}
Directory.Delete(path, recursive); Directory.Delete(path, recursive);
} }
else else