public void CopyTo(IWritableDirectory destination) { foreach (var file in Files) { destination.GetOrCreateFile(file.Name).CopyFrom(file); } foreach (var dir in Directories) { var subDir = destination.GetOrCreateDirectory(dir.Name); dir.CopyTo(subDir); } }
public void CopyTo(IWritableDirectory destination) { for (var i = 0; i < _files.Count; i++) { var c = _files[i]; var destFile = destination.GetOrCreateFile(c.Name); destFile.CopyFrom(c); } for (var i = 0; i < _directories.Count; i++) { var c = _directories[i]; var newDir = destination.GetOrCreateDirectory(c.Name); c.CopyTo(newDir); } }
public IWritableDirectory GetOrCreateDirectory(string name) { if (!_dirInfo.Exists) { _dirInfo.Create(); } var existing = this[name]; return(existing switch { null => new DiskDirectory(name, this, true), IWritableDirectory dir => dir, IFile _ => throw new InvalidOperationException( "The directory already contains a file with this name"), _ => throw new Exception("Unknown exception"), });
public void CopyTo(IWritableDirectory destination) { for (var i = 0; i < _files.Count; i++) { var c = _files[i]; var destFile = destination.GetOrCreateFile(c.Name); using (var destStream = destFile.GetStream()) { c.CopyToStream(destStream); } } for (var i = 0; i < _directories.Count; i++) { var c = _directories[i]; var newDir = destination.GetOrCreateDirectory(c.Name); c.CopyTo(newDir); } }