/// <summary> /// create an abstract directory object /// </summary> /// <param name="path">full path to the directory</param> /// <returns>an abstrcat object</returns> public IDirectoryInfo GetDirectoryInfo(string path) { var pathInfo = MtpPath.GetPathInfo(path); var device = _deviceManager.GetDevice(pathInfo.DeviceName); if (device == null) { throw new DirectoryNotFoundException(String.Format("Device [{0}] not found", pathInfo.DeviceName)); } return(new DirectoryInfo(device, pathInfo.RelativePathOnDevice)); }
/// <summary> /// create an abstract drive info object /// </summary> /// <param name="path">name of the drive</param> /// <returns>an abstrcat object</returns> public IDriveInfo GetDriveInfoForPath(string path) { var pathInfo = MtpPath.GetPathInfo(path); var device = _deviceManager.GetDevice(pathInfo.DeviceName); if (device == null) { throw new DriveNotFoundException(String.Format("Device [{0}] not found", pathInfo.DeviceName)); } var storageObject = device.GetRootStorageObjectFromPath(pathInfo.RelativePathOnDevice); if (storageObject == null) { throw new DriveNotFoundException( String.Format( "No storage object found: Device [{0}], path [{1}]", pathInfo.DeviceName, pathInfo.RelativePathOnDevice)); } return(new DriveInfo(device, storageObject)); }