DeleteByName() public method

public DeleteByName ( String name ) : void
name String
return void
示例#1
0
        public override void Evaluate()
        {
            String targetFile = RegexMatch.Groups[1].Value.Trim();
            String operation  = RegexMatch.Groups[3].Value.Trim().ToUpper();
            String volumeName = RegexMatch.Groups[5].Value.Trim();
            File   file       = null;

            Volume targetVolume = null;

            switch (operation)
            {
            case "FROM":
                targetVolume = GetVolume(volumeName);     // Will throw if not found
                file         = targetVolume.GetByName(targetFile);
                if (file == null)
                {
                    throw new kOSException("File '" + targetFile + "' not found");
                }
                targetVolume.DeleteByName(targetFile);
                break;

            default:
                file = SelectedVolume.GetByName(targetFile);
                if (file == null)
                {
                    throw new kOSException("File '" + targetFile + "' not found");
                }
                SelectedVolume.DeleteByName(targetFile);
                break;
            }

            State = ExecutionState.DONE;
        }
示例#2
0
        public override void Evaluate()
        {
            String targetFile = RegexMatch.Groups[1].Value.Trim();
            String volumeName = RegexMatch.Groups[3].Value.Trim();

            File   file         = null;
            Volume targetVolume = null;

            if (volumeName.Trim() != "")
            {
                targetVolume = GetVolume(volumeName); // Will throw if not found
                file         = targetVolume.GetByName(targetFile);
                if (file == null)
                {
                    throw new kOSException("File '" + targetFile + "' not found", this);
                }
                targetVolume.DeleteByName(targetFile);
            }
            else
            {
                file = SelectedVolume.GetByName(targetFile);
                if (file == null)
                {
                    throw new kOSException("File '" + targetFile + "' not found", this);
                }
                SelectedVolume.DeleteByName(targetFile);
            }

            State = ExecutionState.DONE;
        }