private void DetectKindle() { if (Kindle.Detect()) { } DriveInfo[] drives = DriveInfo.GetDrives(); for (int i = 0; i < drives.Count(); i++) { try { if (drives[i].VolumeLabel == "Kindle" && (userSettings.DevicePath == "" || drives[i].Name.First() != userSettings.DevicePath.First())) { if (MessageBox.Show("A Kindle was detected, set device location to Kindle path?", "AO3 eBook Downloader", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) != MessageBoxResult.No) { userSettings.DevicePath = drives[i].Name + "documents"; this.Dispatcher.Invoke(new Action(() => { deviceLocation.Text = userSettings.DevicePath; })); } break; } } catch (IOException) { continue; } } }
public static bool Detect(Kindle k = null) { // TODO move this out somewhere? DriveInfo[] drives = DriveInfo.GetDrives(); for (int i = 0; i < drives.Count(); i++) { try { if (drives[i].VolumeLabel == "Kindle" && (userSettings.DevicePath == "" || drives[i].Name.First() != userSettings.DevicePath.First())) { if (k != null) { k.DevicePath = drives[i].Name; } return(true); } } catch (IOException) { continue; } } return(false); }