Beispiel #1
0
        /// <summary>
        /// remove a device
        /// </summary>
        /// <param name="driveLetter">drive letter. Example : 'A', 'B', 'C', 'D', ..., 'Z'.</param>
        /// <param name="deviceNumber">number of the device to remove</param>
        /// <returns>true if success, false if failure</returns>
        public static bool RemoveDevice(char driveLetter, uint deviceNumber = 0)
        {
            #region args check

            if (!Char.IsLetter(driveLetter))
            {
                throw new ArgumentException("Must be a letter from A to Z.", "driveLetter");
            }

            #endregion
            string mountPoint = GetMountPoint(driveLetter);
            if (!Load())
            {
                return(false);
            }
            try
            {
                ImDiskAPI.RemoveDevice(mountPoint); // Mount point in the form of a drive letter and colon to create for newly created virtual disk. If this parameter is Nothing/null the virtual disk will be created without a drive letter.
                ImDiskAPI.ForceRemoveDevice(deviceNumber);
                return(true);
            }
            catch (Exception) { }
            return(false);
        }
Beispiel #2
0
 public static void Umount()
 {
     ImDiskAPI.RemoveDevice(driveL + ":\\");
 }