I was making a rmdir command for my COSMOS C# operating system, and all of a sudden I am getting a Exception: System.Exception
error in Visual Studio 2022. It says its on line one of IL2CPU, so I'm not sure how to fix this. It only throws this error when the rmdir function code isn't commented out, so here it is for reference.
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);
}
}
Commenting out the rmdir command fixes it, but I need a rmdir command for a proper filesystem.