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

installation - COSMOS C#: How would I remove the contents of my virtual drive entirely? - Stack Overflow

programmeradmin4浏览0评论

I am making an installer for my OS and I am trying to delete the contents on the drive before installing. However, it keeps exiting with the exception message "Argument is null or empty Parameter name: aDirectory".

Here is my code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.IO;
    using Sys = Cosmos.System;

    namespace VNU
    {
        internal class Installer
        {
            public static void Install()
            {
                try
                {
                    // Delete preinstalled Cosmos files
                    foreach (var dir in Directory.GetDirectories("0:\\"))
                    {
                        Directory.Delete(dir, true);
                    }
                
                    foreach (var file in Directory.GetFiles("0:\\"))
                    {
                        File.Delete(file);
                    }
    
                    // Make the system folders
                    foreach (var dir in Kernel.systemPaths)
                    {
                        Directory.CreateDirectory(dir);
                    }
                }
                catch (Exception ex) { Console.WriteLine("The installer failed: " + ex +      ex.Message);    }
            }
        }
    }

I am expecting it to delete the files and folders, however it raises the exception.

发布评论

评论列表(0)

  1. 暂无评论