I use the following code to get logical drives:
string[] strDrives = Environment.GetLogicalDrives();
but when I want to iterate through it, an exception occurs, with the message:
Drive Not Ready
How can I get just ready drives?
Use DriveInfo to determine if the drive is ready.
foreach (var oneDrive in strDrives)
{
var drive = new DriveInfo(oneDrive)
if (drive.IsReady)
{
// Do something with the drive...
}
}