最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How do I fix `System.Exception` error in COSMOS C#? - Stack Overflow

programmeradmin1浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论