예제 #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);
        }
예제 #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.");
            }
        }
예제 #3
0
파일: File.cs 프로젝트: zeeshananjum/n2cms
        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;
        }
예제 #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);
        }
예제 #5
0
파일: File.cs 프로젝트: zeeshananjum/n2cms
        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));
        }