public static bool Unmount(IntPtr hdc) { if (!FileSystem.mounted.Contains(hdc)) { throw new InvalidOperationException("Not mounted"); } var drive = (IDriveProvider)FileSystem.mounted[hdc]; FileSystem.mounted.Remove(hdc); DriveInfo.DeregisterDriveProvider(drive); return(FileSystem.Uninitialize(hdc)); }