/// <summary>
        /// Mounts a dummy USB with the given gpii key.
        /// </summary>
        /// <param name="keyText"></param>
        /// <returns>Drive letter.</returns>
        internal string MountUsb(string keyText)
        {
            char[] drives = Environment.GetLogicalDrives().Select(d => d.ToUpperInvariant()[0]).ToArray();
            if (drives.Length > 25)
            {
                this.Logger.Write("Too many drives mounted");
                return(null);
            }

            // Pick an arbitrary drive letter that's unused.
            int  n = Environment.TickCount;
            char ch;

            do
            {
                ch = (char)('A' + (n++ % 26));
            } while (drives.Contains(ch));

            string letter = new string(ch, 1);

            // Use a temporary directory for the content.
            string dir = Path.Combine(Path.GetTempPath(), @"mdiag-usb\" + letter);

            Directory.CreateDirectory(dir);
            File.WriteAllText(Path.Combine(dir, ".gpii-user-token.txt"), keyText);

            // Mount it
            this.Logger.Command("subst " + letter + ": " + dir);
            // Tell the system a new USB drive has been added (morphic listens to this)
            FakeUsb.SendNotification(letter, true);

            return(letter);
        }
 /// <summary>
 /// Unmounts a dummy usb drive that was mounted via MountUsb.
 /// </summary>
 /// <param name="letter">The drive letter, returned by MountUsb</param>
 internal void UnmountUsb(string letter)
 {
     // Unmount it
     this.Logger.Command("subst /d " + letter + ":");
     try
     {
         // Remove the temporary directory.
         string dir = Path.Combine(Path.GetTempPath(), "mdiag-usb");
         Directory.Delete(Path.Combine(dir, letter), true);
         Directory.Delete(dir);
     }
     catch (IOException e)
     {
         // ignore
     }
     FakeUsb.SendNotification(letter, false);
 }