public static bool CreateMountPoint(char driveLetter) { #region args check if (!Char.IsLetter(driveLetter)) { throw new ArgumentException("Must be a letter from A to Z.", "driveLetter"); } #endregion string mountPoint = GetMountPoint(driveLetter); string nativePath = @"\Device\ImDisk0"; if (!Load()) { return(false); } try { ImDiskAPI.CreateMountPoint(mountPoint, // Path to empty directory on an NTFS volume, or a drive letter followed by a colon. nativePath); // Target path in native format, for example \Device\ImDisk0 return(true); } catch (Exception) { } return(false); }
// http://stackoverflow.com/questions/7060649/creating-a-virtual-disk-mount-point #if IMDISK public bool CreateRAMDisk() { // Create Empty RAM Disk char driveLetter = ImDiskAPI.FindFreeDriveLetter(); ImDiskAPI.CreateDevice(52428800, 0, 0, 0, 0, ImDiskFlags.DeviceTypeHD | ImDiskFlags.TypeVM, null, false, driveLetter.ToString(), ref deviceID, IntPtr.Zero); string mountPoint = driveLetter + @":\Device\ImDisk0"; ImDiskAPI.CreateMountPoint(mountPoint, deviceID); // Format the Drive for NTFS if (FormatDrive(driveLetter.ToString(), "NTFS", true, 4096, "", false)) { } }