示例#1
0
        protected CsShellDirectory PopulateDictionaries()
        {
            Debug.Print("Populating Dictionaries");
            ActiveShellDirectory = new CsShellDirectory().Create();
            try
            {
                Debug.Print("> Enumerating Files");
                foreach (string ss in Directory.GetFiles(currentPath))
                {
                    FileInfo f = new FileInfo(ss);
                    using (CsShellFile sh = new CsShellFile(ss, SHGFI.SMALLICON | SHGFI.ICON | SHGFI.TYPENAME))
                    {
                        if (!ActiveShellDirectory.Files.Paths.ContainsKey(f.FullName))
                        {
                            ActiveShellDirectory.Files.Paths.Add(f.FullName, sh.GetListItem());
                        }
                        if (!ActiveShellDirectory.Files.IcoPtr.ContainsKey(ss))
                        {
                            ActiveShellDirectory.Files.IcoPtr.Add(f.FullName, sh.IIcon);
                        }
                    }
                }

                Debug.Print("> File Count: {0}", ActiveShellDirectory.Files.Paths.Count);
                Debug.Print("> Enumerating Directories");
                foreach (string ss in Directory.GetDirectories(currentPath))
                {
                    DirectoryInfo        d  = new DirectoryInfo(ss);
                    CsShellFile_ListItem sx = new CsShellFile_ListItem();
                    sx.Path = ss;
                    sx.Name = Path.GetFileName(ss);
                    SHFileInfo sh = Shell32.StrIco(ss, SHGFI.SMALLICON | SHGFI.ICON | SHGFI.TYPENAME);
                    sx.TypeName = sh.szTypeName;
                    if (!ActiveShellDirectory.Directories.Paths.ContainsKey(d.Name))
                    {
                        ActiveShellDirectory.Directories.Paths.Add(d.Name, sx);
                    }
                    if (!ActiveShellDirectory.Directories.IcoPtr.ContainsKey(ss))
                    {
                        ActiveShellDirectory.Directories.IcoPtr.Add(ss, sh.hIcon);
                    }
                    User32.DestroyIcon(sh.hIcon);
                }
                Debug.Print("> Directory Count: {0}", ActiveShellDirectory.Directories.Paths.Count);
            }
            catch (IOException e) {
                MessageBox.Show(e.Message, e.Source);
            }
            catch (Exception e) {
                Debug.Print("{0}", e);
            }
            return(ActiveShellDirectory);
        }
示例#2
0
 public CsShellManager(string Path)
 {
     currentPath      = Path;
     currentShellPath = PopulateDictionaries();
 }