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.