private void FetchContents(PortableDevice portableDevice, PortableDeviceFolder deviceFolder) { try { foreach (var fileObject in deviceFolder.Files) { if (_activeDevice != null && _activeDevice.ImportOption == DeviceImportOption.Never) { break; } if (_activeDevice != null && StoredDevices.SingleOrDefault(p => p.Id.Equals(_activeDevice.Id)) == null) { break; } if (fileObject is PortableDeviceFile) { //if (Common.Utilities.Utility.FileExtensions.IsValidFileExtension(Path.GetExtension(fileObject.Name.ToLower()))) if (Utility.ListValidImageExtensions.Contains(Path.GetExtension(fileObject.Name).ToLower())) { //validFile //Utility.LogMessage("{0} {1}", fileObject.Id, fileObject.Name); string str = (string.IsNullOrEmpty(fileObject.Name) ? Path.GetFileName(fileObject.Id) : Path.GetFileName(fileObject.Name)); if (!File.Exists(Path.Combine(_defaultMediaBackupPath, str))) { //copy the file to device Utility.LogMessage("[FetchContents] [Copy] [{0} {1}]", fileObject.Id, fileObject.Name); portableDevice.CopyFilefromDevice((PortableDeviceFile)fileObject, DefaultMediaBackupPath); //System.Threading.Thread.Sleep(2000); } } } else { FetchContents(portableDevice, (PortableDeviceFolder)fileObject); } } } catch (Exception) { throw; } }
private void FetchContents(PortableDevice portableDevice, PortableDeviceFolder deviceFolder) { try { foreach (var fileObject in deviceFolder.Files) { if (_activeDevice != null && _activeDevice.ImportOption == DeviceImportOption.Never) { break; } if (_activeDevice != null && StoredDevices.SingleOrDefault(p => p.Id.Equals(_activeDevice.Id)) == null) { break; } if (fileObject is PortableDeviceFile) { if (Common.Utilities.Utility.FileExtensions.IsValidFileExtension(Path.GetExtension(fileObject.Name.ToLower()))) { Console.WriteLine("{0} {1}", fileObject.Id, fileObject.Name); string str = (string.IsNullOrEmpty(fileObject.Name) ? Path.GetFileName(fileObject.Id) : Path.GetFileName(fileObject.Name)); if (!File.Exists(Path.Combine(_defaultMediaBackupPath, str))) { Console.WriteLine("{0} {1}", fileObject.Id, fileObject.Name); portableDevice.CopyFilefromDevice((PortableDeviceFile)fileObject, DefaultMediaBackupPath); } } } else { FetchContents(portableDevice, (PortableDeviceFolder)fileObject); } } } catch (Exception) { throw; } }