C # Identify a removable hard drive

  1. using System;  
  2. using System.IO;  
  3. using System.Windows.Forms;  
  4.   
  5. namespace WindowsFormsApplication1  
  6. {  
  7.     public partial class Form1 : Form  
  8.     {  
  9.         public Form1()  
  10.         {  
  11.             InitializeComponent();  
  12.         }  
  13.   
  14.         private void BtnFind_Click(object sender, EventArgs e)  
  15.         {  
  16.             foreach (DriveInfo drive in DriveInfo.GetDrives())  
  17.             {  
  18.                 if (drive.DriveType.Equals(DriveType.Removable))  
  19.                 {  
  20.                     MessageBox.Show(drive.Name.ToString() + "is an external derive.");  
  21.                 }  
  22.   
  23.                 else  
  24.                 {  
  25.                     MessageBox.Show("Not external drive avialible");  
  26.                     return;  
  27.                 }  
  28.             }  
  29.         }  
  30.     }  
  31. }