From 94a329a522ff84e3ff3410b77cbd1a0a7e5c6350 Mon Sep 17 00:00:00 2001 From: walon Date: Thu, 2 Nov 2023 10:47:55 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E4=BF=AE=E5=A4=8DBashUtil.RemoveDir?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Editor/Installer/BashUtil.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Editor/Installer/BashUtil.cs b/Editor/Installer/BashUtil.cs index 428275b..555f3ca 100644 --- a/Editor/Installer/BashUtil.cs +++ b/Editor/Installer/BashUtil.cs @@ -64,20 +64,27 @@ namespace HybridCLR.Editor.Installer { UnityEngine.Debug.Log($"[BashUtil] RemoveDir dir:{dir}"); } - if (!Directory.Exists(dir)) - { - return; - } int maxTryCount = 5; for (int i = 0; i < maxTryCount; ++i) { try { - if (Directory.Exists(dir)) + if (!Directory.Exists(dir)) { - Directory.Delete(dir, true); + return; } + foreach (var file in Directory.GetFiles(dir)) + { + File.SetAttributes(file, FileAttributes.Normal); + File.Delete(file); + } + foreach (var subDir in Directory.GetDirectories(dir)) + { + RemoveDir(subDir); + } + Directory.Delete(dir); + break; } catch (Exception e) {