コード例 #1
0
        private void ScanForUsbDrives()
        {
            // https://github.com/sillsdev/chorus/issues/261
            // some users have problems with their USB drive (hardware?) such that GetDrives throws
            //	an exception, which if not caught, results in a fatal exception for Chorus
            try
            {
                while (_keepRunning)
                {
                    var usbRoots = new SIL.UsbDrive.RetrieveUsbDriveInfo().GetDrives()
                                   .Select(u => u.RootDirectory.FullName);
                    // In Balsa, the boot device (SD Card or USB Stick) shows up as one of the
                    // drives and it shouldn't be used for S/R.  Balsa will be changed to
                    // include a .chorus-hidden file in the root paritions that should not be
                    // used for S/R.  A user can include this file in USB attached drive that
                    // they don't want Chorus to use.
                    var usbDrives = System.IO.DriveInfo.GetDrives()
                                    .Where(d => usbRoots.Contains(d.RootDirectory.FullName) &&
                                           d.RootDirectory.GetFiles(".chorus-hidden").Count() == 0);
                    lock (_usbDrives)
                    {
                        _usbDrives.Clear();
                        _usbDrives.AddRange(usbDrives);
                    }

                    Thread.Sleep(3000);                     // check again after 3 second
                }
            }
            catch (Exception ex)
            {
                ErrorReport.ReportNonFatalException(ex);
            }
        }
コード例 #2
0
ファイル: UsbDriveLocator.cs プロジェクト: samdoss/chorus
 private void ScanForUsbDrives()
 {
     while (_keepRunning)
     {
         var usbRoots = new SIL.UsbDrive.RetrieveUsbDriveInfo().GetDrives()
                        .Select(u => u.RootDirectory.FullName);
         // In Balsa, the boot device (SD Card or USB Stick) shows up as one of the
         // drives and it shouldn't be used for S/R.  Balsa will be changed to
         // include a .chorus-hidden file in the root paritions that should not be
         // used for S/R.  A user can include this file in USB attached drive that
         // they don't want Chorus to use.
         var usbDrives = System.IO.DriveInfo.GetDrives()
                         .Where(d => usbRoots.Contains(d.RootDirectory.FullName) &&
                                d.RootDirectory.GetFiles(".chorus-hidden").Count() == 0);
         lock (_usbDrives)
         {
             _usbDrives.Clear();
             _usbDrives.AddRange(usbDrives);
         }
         Thread.Sleep(3000);                 // check again after 1 second
     }
 }
コード例 #3
0
ファイル: UsbDriveLocator.cs プロジェクト: regnrand/chorus
 private void ScanForUsbDrives()
 {
     while (_keepRunning)
     {
         var usbRoots = new SIL.UsbDrive.RetrieveUsbDriveInfo().GetDrives()
             .Select(u => u.RootDirectory.FullName);
         // In Balsa, the boot device (SD Card or USB Stick) shows up as one of the
         // drives and it shouldn't be used for S/R.  Balsa will be changed to
         // include a .chorus-hidden file in the root paritions that should not be
         // used for S/R.  A user can include this file in USB attached drive that
         // they don't want Chorus to use.
         var usbDrives = System.IO.DriveInfo.GetDrives()
             .Where(d => usbRoots.Contains(d.RootDirectory.FullName) &&
                         d.RootDirectory.GetFiles(".chorus-hidden").Count() == 0);
         lock (_usbDrives)
         {
             _usbDrives.Clear();
             _usbDrives.AddRange(usbDrives);
         }
         Thread.Sleep(3000); // check again after 1 second
     }
 }