Пример #1
0
 public override bool IsRecognizedOn(Drive drive)
 {
     if (!DriveTypeCorrect(drive))
     {
         return(false);
     }
     for (var i = 1; i < 10; i++)    // retries, in case of pesky IOException "drive not ready" errors when trying to read the volume label. What is that about...
     {
         try {
             var localdrive = drive as LocalDrive;
             if (localdrive == null)
             {
                 return(false);
             }
             return(localdrive.driveinfo.VolumeLabel == label);
         } catch (IOException e) {
         }
         System.Threading.Thread.Sleep(100);
     }
     return(false);
 }
Пример #2
0
 public bool FindOnDrives(IEnumerable <Drive> drives)
 {
     if (drives == null)
     {
         return(false);
     }
     lock (drives) {
         foreach (var drive in drives)                   // may take some time!
         {
             Console.WriteLine(drive);
             current_recognition = RecognizedOnDrive(drive);
             current_drive       = drive;
             if (!(current_recognition is null))
             {
                 Console.WriteLine("Detected " + this.Label + " on " + drive.ToString() + " " + (drive is NetworkDrive ? "(network)" : "(local)"));
                 this.current_drive = drive;
                 return(true);
             }
         }
     }
     Console.WriteLine("Missing " + this.Label);
     return(false);
 }
Пример #3
0
 public void Reset()
 {
     this.IsPresent     = false;
     this.current_drive = null;
 }
Пример #4
0
 internal string ToString(Drive drive)
 {
     return(drive.ToString() + "+" + rootpath);
 }
Пример #5
0
 protected bool DriveTypeCorrect(Drive drive)
 {
     return((drive is NetworkDrive && CanRecognizeNetworkShare) ||
            (drive is LocalDrive && CanRecognizeLocalDrive));
 }
Пример #6
0
 public abstract bool IsRecognizedOn(Drive drive);