Ejemplo n.º 1
0
        /// <summary>
        /// gets an abstract collection of files that are contained by by the directory
        /// </summary>
        /// <param name="pattern">a search patter for example *.mp3</param>
        /// <returns>a collection of abstracted files</returns>
        public IFileInfo[] GetFiles(string pattern)
        {
            CheckObjectExists();

            var childFileObjects = DeviceObject.GetFiles(pattern);

            return(childFileObjects.Select(file => new FileInfo(_device, file, MtpPath.Combine(_path, file.Name))).ToArray());
        }
        /// <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));
        }
Ejemplo n.º 3
0
        /// <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));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// gets an abstract collection of directories that are contained by the directory
        /// </summary>
        /// <param name="pattern">a search patter for example *.*</param>
        /// <returns>a collection of abstracted files</returns>
        public IDirectoryInfo[] GetDirectories(string pattern)
        {
            CheckObjectExists();

            var childFolderObjects = DeviceObject.GetFolders(pattern);

            return(childFolderObjects.Select(folder => new DirectoryInfo(_device, folder, MtpPath.Combine(_path, folder.Name))).ToArray());
        }