AccessProviderSample.AccessDBProvider.RemoveDrive C# (CSharp) Method

RemoveDrive() protected method

Removes a drive from the provider.
protected RemoveDrive ( PSDriveInfo drive ) : PSDriveInfo
drive PSDriveInfo The drive to remove.
return PSDriveInfo
        protected override PSDriveInfo RemoveDrive(PSDriveInfo drive)
        {
            // check if drive object is null
            if (drive == null)
            {
                WriteError(new ErrorRecord(
                    new ArgumentNullException("drive"),
                    "NullDrive",
                    ErrorCategory.InvalidArgument,
                    drive)
                );

                return null;
            }

            // close ODBC connection to the drive
            AccessDBPSDriveInfo accessDBPSDriveInfo = drive as AccessDBPSDriveInfo;

            if (accessDBPSDriveInfo == null)
            {
                return null;
            }
            accessDBPSDriveInfo.Connection.Close();

            return accessDBPSDriveInfo;
        }