public IFile CopyTo(string destFileName, bool overwrite) { EnsureExists(); if (FileSystem == null) { throw new InvalidOperationException("FileMock FileSystem property should be set before copying is possible."); } var file = FileSystem.GetFile(destFileName); if (!file.Exists) { file = new FileMock(Path.GetFileName(destFileName), _data.ToArray()) { FullName = destFileName }; FileSystem.Add(file); } else if (overwrite) { file.WriteAllBytes(this.ReadAllBytes()); } else { throw new IOException(string.Format("Cannot copy '{1}' to '{0}': file already exists.", destFileName, this.FullName)); } return(file); }
public void Add([NotNull] FileMock file) { file.FileSystem = this; _items.Add(file); }
public void Add([NotNull] FileMock file) { file.Directory = this; _items.Add(file); }