Example #1
0
 /// <inheritdoc/>
 public void Dispose()
 {
     if (disk != null)
     {
         disk.Close();
     }
     if (volume != null)
     {
         volume.Close();
     }
     disposed = true;
 }
Example #2
0
 /// <summary>
 /// Instantiates a new instance of <see cref="WindowsDisk"/>.
 /// </summary>
 /// <param name="name">The drive letter.</param>
 public WindowsDisk(string name)
 {
     rootPath = Path.GetPathRoot(Path.GetFullPath(name)).TrimEnd(Path.DirectorySeparatorChar);
     volume   = new DiskDevice(@"\\.\" + rootPath, true);
     try
     {
         DiskDevice.STORAGE_DEVICE_NUMBER devNumber = volume.QueryDeviceNumber();
         disk = new DiskDevice(devNumber.PhysicalDrive, true);
     }
     catch
     {
         volume.Close();
         throw;
     }
 }