Wie repariere ich `System.Exception` -Fehler in Cosmos C#? (Das Betriebssystem entwickelt Kosmos)C#

Ein Treffpunkt für C#-Programmierer
Guest
 Wie repariere ich `System.Exception` -Fehler in Cosmos C#? (Das Betriebssystem entwickelt Kosmos)

Post by Guest »

Ich habe einen RMDIR -Befehl für mein Betriebssystem Cosmos C# erstellt, und plötzlich erhalte ich eine Ausnahme: System.Exception Fehler in Visual Studio 2022. Ich bin mir nicht sicher, wie ich das beheben soll. Es wirft diesen Fehler nur aus, wenn der RMDIR-Funktionscode nicht kommentiert wird. Hier ist er hier als Referenz.

Code: Select all

void rmdir(string input)
{
try
{
if (string.IsNullOrEmpty(input))
{
Console.WriteLine("Error: input cannot be empty.");
return;
}

string fixed_input = input.Substring(6).Trim();
if (string.IsNullOrEmpty(fixed_input))
{
Console.WriteLine("Error: Directory name cannot be empty.");
return;
}

string path = current_path + fixed_input;

if (!Directory.Exists(path))
{
Console.WriteLine("Error: Directory does NOT exist.");
return;
}

if (Directory.GetFileSystemEntries(path).Length > 0)
{
Console.WriteLine("Error: Directory isn't empty.");
return;
}

Directory.Delete(path);
Console.WriteLine($"Directory '{fixed_input} deleted successfully.");
}
catch (Exception e)
{
Console.WriteLine("Error occurred: " + e.Message);
}

}
kommentiert den Befehl rmdir behebt es, aber ich brauche einen RMDIR -Befehl für ein ordnungsgemäßes Dateisystem.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post