public ContentItem CopyTo(ContentItem destination) { AbstractDirectory d = AbstractDirectory.EnsureDirectory(destination); string to = Combine(d.Url, Name); if (FileSystem.FileExists(to)) { throw new NameOccupiedException(this, d); } FileSystem.CreateDirectory(to); Directory copy = new Directory(FileSystem.GetDirectory(to), d); copy.Set(FileSystem); foreach (File f in GetFiles()) { f.CopyTo(copy); } foreach (Directory childDir in GetDirectories()) { childDir.CopyTo(copy); } return(copy); }
public override void AddTo(ContentItem newParent) { if (newParent is AbstractDirectory) { AbstractDirectory dir = EnsureDirectory(newParent); string to = Combine(dir.Url, Name); if (FileSystem.FileExists(to)) { throw new NameOccupiedException(this, dir); } if (FileSystem.DirectoryExists(Url)) { FileSystem.MoveDirectory(Url, to); } else { FileSystem.CreateDirectory(to); } Parent = newParent; } else if (newParent != null) { throw new N2Exception(newParent + " is not a Directory. AddTo only works on directories."); } }
public File(FileData file, AbstractDirectory parent) { Parent = parent; NewName = file.Name; Name = file.Name; Title = file.Name; Size = file.Length; Updated = file.Updated; Created = file.Created; }
public void MoveTo(ContentItem destination) { AbstractDirectory d = EnsureDirectory(destination); string to = Combine(d.Url, Name); if (FileSystem.FileExists(to)) { throw new NameOccupiedException(this, d); } FileSystem.MoveDirectory(Url, to); }
public ContentItem CopyTo(ContentItem destination) { AbstractDirectory d = AbstractDirectory.EnsureDirectory(destination); string to = Combine(d.LocalUrl, Name); if (FileSystem.FileExists(to)) { throw new NameOccupiedException(this, d); } FileSystem.CopyFile(LocalUrl, to); return(d.GetChild(Name)); }