can any one say how to avoid foreach loop because drive letter is compared to all drives ithink its laggs my application
public static bool IsDriveReady(char driveLetter)
{
DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo driveInfo in allDrives)
{
char drive = driveInfo.Name.ToUpper(CultureInfo.InvariantCulture)[0];
if (drive.CompareTo(driveLetter) == 0)
{
return driveInfo.IsReady;
}
}
return false;
}