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;
}

Madan ShekarRank #428 · 5.9K reputationPosted Feb 19, 2019, 7:23 PM EST
Madan ShekarRank #428 · 5.9K reputationPosted Feb 19, 2019, 2:25 AM EST
Nagendra Panyam175 reputationPosted Feb 19, 2019, 7:09 PM EST
Salman BegRank #284 · 8.8K reputationPosted Feb 19, 2019, 7:22 PM EST