Friday, April 1, 2011

Detecting Removable Drives in C#.Net

This task is very simple.

Using the following code, you can find removable drives and their letters in your system.


 

System.IO.DriveInfo [] drives = System.IO.DriveInfo.GetDrives ();


foreach (System.IO.DriveInfo drive in drives)

{


if (drive.DriveType == System.IO.DriveType.Removable)

{


Console.WriteLine ("Found removable drive {0}", drive.Name);


Console.ReadLine();

}

}


 


 

I hope it will help somebody. J

Testing Challenge

Can you find more than 20 defects in the below image? Write your defects in the comments section.