コード例 #1
0
        /**Carga el directorio pasado por parametros al TreeNode del treeView*/
        private void LoadSubDirectories(string dir, CheckItem td, TreeView treeView, string categName)
        {
            // Get all subdirectories
            string[] subdirectoryEntries = Directory.GetDirectories(dir);
            // Loop through them to see if they have any other subdirectories
            DirectoryInfo di;
            CheckItem     tds;
            bool          exists;

            foreach (string subdirectory in subdirectoryEntries)
            {
                if (AppMAnager.DirectoryHasMediaFiles(subdirectory))
                {
                    di     = new DirectoryInfo(subdirectory);
                    exists = DBManager.MediaFilesRepo.Exists(di.FullName);

                    if (td != null)
                    {
                        tds = td.AddChild(di.Name, exists, true);
                    }
                    else
                    {
                        tds = new CheckItem(di.Name, exists, true);
                        treeView.Items.Add(tds);
                    }

                    //tds.StateImageIndex = 0;
                    tds.Tag = di;

                    LoadSubDirectories(subdirectory, tds, null, categName);
                    LoadFiles(subdirectory, tds, null, categName);
                    //UpdateProgress();
                }
            }
        }
コード例 #2
0
        /**Carga los ficheros encontrados hacia un nodo del treeView*/
        private void LoadFiles(string dir, CheckItem td, TreeView treeView, string categName)
        {
            IEnumerable <string> Files = Directory.GetFiles(dir, "*.*", SearchOption.TopDirectoryOnly).Where(s => AppMAnager.TYPES_MEDIA.Contains(Path.GetExtension(s).ToLower()));

            // Loop through them to see files
            bool exists;

            foreach (string file in Files)
            {
                FileInfo  fi = new FileInfo(file);
                CheckItem tds;

                if (fi.Extension.Length > 0)
                {
                    exists = DBManager.MediaFilesRepo.Exists(fi.FullName);
                    if (exists)
                    {
                        existingFilesInDB.Add("(" + categName + ")" + fi.FullName);
                    }

                    if (td != null && fi.Extension.Length > 0)
                    {
                        tds = td.AddChild(fi.Name, exists, false);
                    }
                    else
                    {
                        tds = new CheckItem(fi.Name, exists, false);
                        treeView.Items.Add(tds);
                    }

                    tds.Tag = fi;
                    //tds.StateImageIndex = 1;
                    //  UpdateProgress();
                }
            }
        }