Cornerstone.Tools.DriveInfoHelper.GetDriveInfo C# (CSharp) Method

GetDriveInfo() public static method

Gets the DriveInfo object for the given driveletter When the object was created before it will be returned from cache.
public static GetDriveInfo ( string drive ) : DriveInfo
drive string
return System.IO.DriveInfo
        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];
        }