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

No comments:

Post a Comment