public static DriveInfo GetDriveInfo(string drive)
{
if (drive == null)
return null;
lock (syncRoot) {
// if this is the first request create the driveinfo collection cache
if (driveInfoPool == null)
driveInfoPool = new Dictionary<string, DriveInfo>();
if (!driveInfoPool.ContainsKey(drive)) {
try {
driveInfoPool.Add(drive, new DriveInfo(drive));
}
catch (Exception e) {
logger.Error("Error retrieving driveinfo object for '{0}': {1}", drive, e.Message);
return null;
}
}
}
return driveInfoPool[drive];
}