void LoadDeivce() { this.mWorker = new System.Threading.Thread((System.Threading.ThreadStart) delegate { try { if (mDriveList != null) { for (int i = 0; i < mDriveList.Count; i++) { mDriveList[i].Close(); } } DriveList.Invoke((MethodInvoker) delegate { DriveList.Items.Clear(); }); l_Message.Invoke((MethodInvoker) delegate { l_Message.Text = "正在加载驱动器..."; }); b_RefreshDrive.Invoke((MethodInvoker) delegate { b_RefreshDrive.Enabled = false; }); mDriveList = ParrotLibs.StartHere.GetFATXDrives().ToList(); if (Properties.Settings.Default.RecentLoadFiles != null) { foreach (string sPathToFile in Properties.Settings.Default.RecentLoadFiles) { if (System.IO.File.Exists(sPathToFile)) { try { ParrotLibs.Drive sDrive = new ParrotLibs.Drive(sPathToFile); if (sDrive.IsFATXDrive()) { mDriveList.Add(sDrive); } } catch (Exception e) { if (!e.Message.Contains("being used")) { MessageBox.Show("An exception was thrown: " + e.Message + "\r\n\r\nStack Trace:\r\n" + e.StackTrace); } else { continue; } } } } } List <ListViewItem> sListView = new List <ListViewItem>(); for (int i = 0; i < mDriveList.Count; i++) { try { ListViewItem sDriveItem = new ListViewItem(mDriveList[i].Name); if (mDriveList[i].DriveType == ParrotLibs.DriveType.HardDisk) { sDriveItem.ImageIndex = 0; sDriveItem.SubItems.Add(mDriveList[i].DeviceIndex.ToString()); } else if (mDriveList[i].DriveType == ParrotLibs.DriveType.USB) { sDriveItem.ImageIndex = 1; sDriveItem.SubItems.Add(System.IO.Path.GetPathRoot(mDriveList[i].USBPaths[0])); } else { sDriveItem.ImageIndex = 2; sDriveItem.SubItems.Add(System.IO.Path.GetFileName(mDriveList[i].FilePath)); } sDriveItem.SubItems.Add(mDriveList[i].LengthFriendly); sDriveItem.Tag = mDriveList[i]; sListView.Add(sDriveItem); } catch (Exception e) { if (!e.Message.Contains("being used")) { MessageBox.Show("An exception was thrown: " + e.Message + "\r\n\r\nStack Trace:\r\n" + e.StackTrace); } else { continue; } } } DriveList.Invoke((MethodInvoker) delegate { DriveList.Items.AddRange(sListView.ToArray()); }); l_Message.Invoke((MethodInvoker) delegate { if (sListView.Count == 0) { l_Message.Text = "未发现驱动器..."; } else { l_Message.Text = sListView.Count.ToString() + "个驱动器被加载!"; } }); b_RefreshDrive.Invoke((MethodInvoker) delegate { b_RefreshDrive.Enabled = true; }); } catch (Exception e) { if (!e.Message.Contains("being used")) { MessageBox.Show("An exception was thrown: " + e.Message + "\r\n\r\nStack Trace:\r\n" + e.StackTrace); } } }); mWorker.Start(); }