Hi,
The exception:
2025-04-08 16:09:51,501 [1] ERROR GssdDesktopClient.Maui.ViewModels.CopyViewModel - DeleteFolderCommandExcute System.IO.IOException: No mapping for the Unicode character exists in the target multi-byte code page. : 'E:\גגגגגגג'. at System.IO.FileSystem.GetFindData(String fullPath, Boolean isDirectory, Boolean ignoreAccessDenied, WIN32_FIND_DATA& findData) at System.IO.FileSystem.RemoveDirectory(String fullPath, Boolean recursive) at System.IO.DirectoryInfo.Delete(Boolean recursive) at GssdDesktopClient.Maui.ViewModels.ViewDevicesViewModel.<>c__DisplayClass95_0.<DeleteFolderCommandExcute>b__0() in C:\Applications\GssdDesktopClient\GssdDesktopClient.Maui\ViewModels\ViewDevicesViewModel.cs:line 1515 at System.Security.Principal.WindowsIdentity.<>c__DisplayClass74_0.<RunImpersonatedInternal>b__0(Object <p0>) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Security.Principal.WindowsIdentity.RunImpersonatedInternal(SafeAccessTokenHandle token, Action action) at GssdDesktopClient.Maui.ViewModels.ViewDevicesViewModel.DeleteFolderCommandExcute(Object param) in C:\Applications\GssdDesktopClient\GssdDesktopClient.Maui\ViewModels\ViewDevicesViewModel.cs:line 1499
This is my code:
It happened in fat 32. and happened from times to times. It happened in windows 10 machine. I develope the code in .net 9 on maui. Steps: 1.insert the fat 32. 2.reading the inserted drive. 3.reading the selected path. 4.delete the selected path.
This is my code:
if (Directory.Exists(SelectedSourceItem.Path))
{
var viewDeviceItem = param as ViewDeviceItem;
if (viewDeviceItem != null)
{
var dir = new DirectoryInfo(viewDeviceItem.Path);
dir.Delete(true);
}
}
@Rob Caplan - MSFT regarding your answer:
Is it your solution using
Directory.EnumerateFiles ?
using System;
using System.IO;
class Program
{
static void Main()
{
string directoryPath = @"C:\path\to\your\directory"; // Specify your directory path here
try
{
// Delete all files in the directory
foreach (var file in Directory.EnumerateFiles(directoryPath))
{
File.Delete(file);
}
// Delete all subdirectories in the directory
foreach (var subDirectory in Directory.EnumerateDirectories(directoryPath))
{
Directory.Delete(subDirectory, true); // true to delete subdirectories and files inside them
}
// Delete the directory itself
Directory.Delete(directoryPath, false); // false because we’ve already deleted the contents
Console.WriteLine("Directory and its contents have been deleted.");
}
catch (Exception ex)
{
Console.WriteLine($"An error occurred: {ex.Message}");
}
}
}