kOS.Volume.SaveFile C# (CSharp) Method

SaveFile() public method

public SaveFile ( File file ) : bool
file System.IO.File
return bool
        public virtual bool SaveFile(File file)
        {
            DeleteByName(file.Filename);
            files.Add(file);

            return true;
        }

Usage Example

Ejemplo n.º 1
0
        public override void Evaluate()
        {
            String targetFile = RegexMatch.Groups[1].Value.Trim();
            String volumeName = RegexMatch.Groups[4].Value.Trim();
            String operation  = RegexMatch.Groups[2].Value.Trim().ToUpper();

            Volume targetVolume = GetVolume(volumeName); // Will throw if not found

            File file = null;

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

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

            State = ExecutionState.DONE;
        }