SecureDelete.WipeObjects.DriveWipeObject.AddDrive C# (CSharp) Method

AddDrive() public method

Add a drive
public AddDrive ( char drive ) : bool
drive char
return bool
        public bool AddDrive(char drive)
        {
            drive = char.ToUpper(drive);

            if(drive < 'A' || drive > 'Z') {
                return false;
            }

            // check if the drive is already in the category
            if(drives.Contains(drive)) {
                return true;
            }

            drives.Add(drive);
            return true;
        }

Usage Example

        public void InsertDrive(char name, bool wipeFreeSpace, bool wipeClusterTips, bool wipeMft)
        {
            if(_logger != null && _testMode) {
                _logger.LogMethodCall(name, wipeFreeSpace, wipeClusterTips, wipeMft);
            }

            if(_session == null || _afterWipe) {
                return;
            }

            DriveWipeObject drive = new DriveWipeObject();
            drive.AddDrive(name);
            drive.WipeMethodId = WipeOptions.DefaultWipeMethod;
            drive.WipeFreeSpace = wipeFreeSpace;
            drive.WipeClusterTips = wipeClusterTips;
            drive.WipeMFT = wipeMft;

            // add to the list
            _session.BridgeItems.Add(drive);

            // report to session
            if(reportActions) {
                ActionErrorReporter.ReportError(_session, _afterWipe, ErrorSeverity.Low,
                                                DriveInsertOperation, name);
            }
        }