Example #1
0
        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);
        }
Example #2
0
        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.");
            }
        }
Example #3
0
        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;
        }
Example #4
0
        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);
        }
Example #5
0
        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));
        }