示例#1
0
 public static void FillTreeView(CFolderCollection folders, TreeNodeCollection tnc)
 {
     for (int i = 0; i < folders.Count; i++)
     {
         int selectfoldericonindex = folders[i].IconIndex == CommVar.CloseFolderIconIndex ? CommVar.OpenFolderIconIndex : folders[i].IconIndex;
         FillTreeView(folders[i].Folders, tnc.Add(folders[i].Name, folders[i].Name, folders[i].IconIndex, selectfoldericonindex).Nodes);
     }
 }
示例#2
0
        public static void FolderInfo2CFolder(CFileCollection files, CFolderCollection folders, DirectoryInfo di, CommVar.Plugins[] Plugins, bool getpath)
        {
            foreach (DirectoryInfo d in di.GetDirectories())
            {
                try
                {
                    if (!IsNormalFileSystem(d.Attributes))
                    {
                        continue;
                    }
                    CFolder cf = new CFolder();
                    cf.Name        = d.Name;
                    cf.CreatedTime = d.CreationTimeUtc;
                    FolderInfo2CFolder(cf.Files, cf.Folders, d, Plugins, getpath);
                    folders.Add(cf);
                    OnFolderAdded(null, new FolderAddedEventArgs(cf));
                }
                catch (Exception ex)
                {
                    MessageBox.Show("A___" + ex.Message);
                }
            }

            foreach (FileInfo fi in di.GetFiles())
            {
                if (!IsNormalFileSystem(fi.Attributes))
                {
                    continue;
                }

                try
                {
                    CFile cfile = new CFile(fi);
                    if (getpath)
                    {
                        cfile.Path = fi.FullName;
                    }
                    files.Add(cfile);
                    OnFileAdded(null, new FileAddedEventArgs(cfile));

                    bool setplugins = false;
                    for (int i = 0; i < Plugins.Length; i++)
                    {
                        try
                        {
                            switch (Plugins[i].pt)
                            {
                            case CommVar.PluginsType.Extract:
                            {
                                CFolder temp =
                                    (CFolder)Plugins[i].mi.Invoke(null, new object[] { fi.FullName });
                                temp.AssociateIconExtension = cfile.Extension;
                                temp.Size         = cfile.Size;
                                temp.FolderType   = CommVar.FolderType.ExtractFolder;
                                temp.SpecialItem  = true;
                                cfile.SpecialItem = true;
                                folders.Add(temp);
                                setplugins = true;
                            }
                            break;
                            }

                            if (setplugins)
                            {
                                break;
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("B___" + ex.Message);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("C___" + ex.Message);
                }
            }
        }