예제 #1
0
파일: FolderItem.cs 프로젝트: fizikci/Cinar
        public FolderItem AddExistingFolder(FolderItem folderItem, string path)
        {
            if(this.Items[folderItem.Name]!=null)
                throw new Exception("There is already a folder with the same name");

            this.Items.Add(folderItem);

            if (!Directory.Exists(folderItem.Path))
                Directory.CreateDirectory(folderItem.Path);

            foreach (var subFolderPath in Directory.GetDirectories(path))
            {
                folderItem.AddExistingFolder(new FolderItem()
                    {
                        Name = System.IO.Path.GetFileName(subFolderPath)
                    }, subFolderPath);
            }
            foreach (var filePath in Directory.GetFiles(path))
            {
                folderItem.AddExistingItem(new FileItem()
                {
                    Name = System.IO.Path.GetFileName(filePath)
                }, filePath);

            }

            Solution.Modified = true;

            return folderItem;
        }
예제 #2
0
파일: FolderItem.cs 프로젝트: fizikci/Cinar
 public FolderItem AddNewFolder(FolderItem item)
 {
     this.Items.Add(item);
     int i = 2; string newName = item.Name;
     while (Directory.Exists(item.Path)) item.Name = newName + " (" + (i++) + ")";
     Directory.CreateDirectory(item.Path);
     Solution.Modified = true;
     return item;
 }