From 543ecbf417146515243a55715de0541d213726a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20W=C4=85sowski?= Date: Tue, 2 Dec 2025 01:15:48 +0100 Subject: [PATCH] Fix exception when deleting a non-empty directory (#20194) --- .../Platform/Storage/FileIO/BclStorageItem.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Base/Platform/Storage/FileIO/BclStorageItem.cs b/src/Avalonia.Base/Platform/Storage/FileIO/BclStorageItem.cs index 212b983da1..560f894b0d 100644 --- a/src/Avalonia.Base/Platform/Storage/FileIO/BclStorageItem.cs +++ b/src/Avalonia.Base/Platform/Storage/FileIO/BclStorageItem.cs @@ -58,7 +58,17 @@ internal abstract class BclStorageItem(FileSystemInfo fileSystemInfo) : IStorage _ => null }; - internal static void DeleteCore(FileSystemInfo fileSystemInfo) => fileSystemInfo.Delete(); + internal static void DeleteCore(FileSystemInfo fileSystemInfo) + { + if (fileSystemInfo is DirectoryInfo directoryInfo) + { + directoryInfo.Delete(true); + } + else + { + fileSystemInfo.Delete(); + } + } internal static Uri GetPathCore(FileSystemInfo fileSystemInfo) {