Exemple #1
0
        public ManagedFolder CreateFolder(string foldername)
        {
            var folder = new ManagedFolder($"{_path}\\{foldername}");

            SubFolders.Add(folder);
            return(folder);
        }
Exemple #2
0
        AddSubFolder(TFolderMetaData subFolderMetaData)
        {
            ComponentFolder <TId, TFolderMetaData, TComponentMetaData> subFolder =
                new ComponentFolder <TId, TFolderMetaData, TComponentMetaData>(subFolderMetaData);

            SubFolders.Add(subFolder);

            return(subFolder);
        }
Exemple #3
0
 public FolderViewModel(string path, FolderViewModel parent = null)
 {
     Path   = path;
     Parent = parent;
     if (!string.IsNullOrEmpty(path) && Directory.GetDirectories(Path).Any())
     {
         SubFolders.Add(new FolderViewModel(string.Empty, this));
     }
 }
Exemple #4
0
        //public Folder()
        //    : this("C:") { }

        public Folder()
        {
            if (SubFolders == null)
            {
                SubFolders = new ObservableCollection <Folder>();
            }
            foreach (var dir in Directory.GetLogicalDrives())
            {
                Folder folder = new Folder(dir);
                SubFolders.Add(folder);
            }
        }
Exemple #5
0
        public void CreateSubDirectory(string subfolder)
        {
            var subdir = Path.Combine(BaseDir, subfolder);

            SubFolders.Add(subdir);

            if (!Directory.Exists(subdir))
            {
                Directory.CreateDirectory(subdir);

                Logger($"Directory '{subdir}' has been created!");
            }
        }
        /// <summary>
        /// Selects the folder to Filter.
        /// </summary>
        internal void SelectFolder()
        {
            using (WF.FolderBrowserDialog fbd = new WF.FolderBrowserDialog())
            {
                if (!string.IsNullOrEmpty(Properties.Settings.Default.LastTracked))
                {
                    if (Directory.Exists(Properties.Settings.Default.LastTracked))
                    {
                        fbd.SelectedPath = Properties.Settings.Default.LastTracked;
                    }
                }

                fbd.ShowNewFolderButton = false;
                var dr = fbd.ShowDialog();

                switch (dr)
                {
                case WF.DialogResult.OK:
                case WF.DialogResult.Yes:
                    WatchedFolder = fbd.SelectedPath;

                    if (Directory.Exists(WatchedFolder))
                    {
                        Status = _normalStates[1];

                        DirectoryInfo dInf = new DirectoryInfo(WatchedFolder);
                        foreach (var subDir in dInf.GetDirectories("*", SearchOption.TopDirectoryOnly))
                        {
                            var folder = new FolderExclude(subDir.Name, subDir.FullName)
                            {
                                Exclude = false
                            };
                            folder.PropertyChanged += Folder_PropertyChanged;
                            SubFolders.Add(folder);
                        }

                        Properties.Settings.Default.LastTracked = WatchedFolder;
                        Properties.Settings.Default.Save();
                        BorderColor = Brushes.Green;
                    }
                    else
                    {
                        BorderColor = Brushes.Red;
                    }
                    break;

                default:
                    break;
                }
            }
        }
Exemple #7
0
 /// <summary>
 /// Adds the subfolder structure to the subfolder list.
 /// </summary>
 private void fillSubfolders()
 {
     foreach (var child in Info.GetDirectories())
     {
         try
         {
             SubFolders.Add(new Folder(child.FullName));
         }
         catch (UnauthorizedAccessException)
         {
             UnavailableFolders.Add(child.FullName);
         }
     }
 }
Exemple #8
0
 private void GetSubFolders(bool value)
 {
     if (value && SubFolders.Any(o => string.IsNullOrEmpty(o.FolderName)))
     {
         SubFolders.Clear();
         var subfolders = Directory.GetDirectories(Path);
         foreach (var item in subfolders)
         {
             try
             {
                 SubFolders.Add(new FolderViewModel(item, this));
             }
             catch (Exception e) { }
         }
     }
 }
Exemple #9
0
 public void LoadSubFolders(bool loadChild)
 {
     SubFolders.Clear();
     try
     {
         foreach (var subFolderPath in _model.GetSubDirectories())
         {
             var subFolder = new FolderViewModel(subFolderPath);
             if (loadChild)
             {
                 subFolder.LoadSubFolders(false);
             }
             SubFolders.Add(subFolder);
         }
     }
     catch (Exception ex) { }
 }
        public void AddElement(ProjectElementBase element)
        {
            if (element is Project)
            {
                Projects.Add(element as Project);
                element.Parent = this;
                return;
            }

            if (element is SolutionFolder)
            {
                SubFolders.Add(element as SolutionFolder);
                element.Parent = this;
                return;
            }
            throw new Exception("Not correct type of item");
        }
Exemple #11
0
 public UserDirectory(string path, PackageComponentsComponentItemsFolder parentItemsFolder, bool isTopLevel) : base(path, parentItemsFolder)
 {
     IsTopLevel = isTopLevel;
     if (Path.Length <= 256)
     {
         if (System.IO.Directory.Exists(Path))
         {
             foreach (var dir in System.IO.Directory.EnumerateDirectories(Path))
             {
                 SubFolders.Add(new UserDirectory(dir, parentItemsFolder, false));
             }
             foreach (var file in System.IO.Directory.EnumerateFiles(path))
             {
                 Files.Add(new UserFile(file, parentItemsFolder));
             }
         }
     }
 }
        public void AddElementRange(IList <ProjectElementBase> elements)
        {
            foreach (ProjectElementBase e in elements)
            {
                if (e is Project)
                {
                    Projects.Add(e as Project);
                    e.Parent = this;
                    continue;
                }

                if (e is SolutionFolder)
                {
                    SubFolders.Add(e as SolutionFolder);
                    e.Parent = this;
                    continue;
                }
                throw new Exception("Not correct type of item");
            }
        }
Exemple #13
0
        private void LoadSubFolders(DirectoryInfo dir)
        {
            SubFolders.Clear();
            var securityTmp = dir.GetAccessControl();

            if (!securityTmp.AreAccessRulesProtected || !securityTmp.AreAuditRulesProtected)
            {
                var subDirs = dir.GetDirectories();
                if (subDirs.Length > 0)
                {
                    for (int i = 0; i < subDirs.Length; i++)
                    {
                        if ((subDirs[i].Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
                        {
                            FolderElement tmpFolder = new FolderElement(new DirectoryInfo(subDirs[i].FullName));
                            tmpFolder.Parent = this;
                            SubFolders.Add(tmpFolder);
                        }
                    }
                }
            }
        }
Exemple #14
0
        private void FillInnerFoldersList()
        {
            IEnumerable <string> dirs = null;

            dirs = Directory.EnumerateDirectories(Path, "*", SearchOption.TopDirectoryOnly);

            if (dirs != null)
            {
                try
                {
                    var exceptions = new ConcurrentQueue <Exception>();

                    Parallel.ForEach(dirs, directory =>
                    {
                        try
                        {
                            FolderItem baseFolder = new FolderItem(directory);
                            SubFolders.Add(baseFolder);
                            foreach (var item in baseFolder.log)
                            {
                                log.Add(item);
                            }
                        }
                        catch (Exception e)
                        {
                            exceptions.Enqueue(e);
                        }
                    });
                    if (exceptions.Count > 0)
                    {
                        throw new AggregateException(exceptions);
                    }
                }
                catch (AggregateException e)
                {
                    throw e;
                }
            }
        }
Exemple #15
0
 public void AddItem(IFolder folder)
 {
     SubFolders.Add(folder);
 }
 public bool CreateFolder(string name)
 {
     return(SubFolders.Add(name) != null);
 }