Exemplo n.º 1
0
        public void OpenDir(string dir)
        {
            if (dir.EndsWith(".lnk"))
            {
                dir = IconGetter.GetExePathFromInk(dir);
            }

            var list = _searching ? _searchNodeList : _curRoot.GetChilds();

            foreach (var node in list)
            {
                var nodeName = node.GetVal();
                if (nodeName.EndsWith(".lnk"))
                {
                    nodeName = IconGetter.GetExePathFromInk(nodeName);
                }
                if (nodeName == null || !nodeName.Equals(dir))
                {
                    continue;
                }
                InitOrderList(_curRoot = node);
                _skipped = 0;
            }

            if (!_searching)
            {
                return;
            }
            _searching = false;
            _searchNodeList.Clear();
        }
Exemplo n.º 2
0
        private static void ProcessDirectory(string dir, TreeNode <string> parent)
        {
            var lnkDir = new List <string>();

            if (dir.EndsWith(".lnk"))
            {
                dir = IconGetter.GetExePathFromInk(dir);
            }

            try
            {
                // Process the list of files found in the directory.
                var fileEntries = Directory.GetFiles(dir.Replace("\\", "/"));
                foreach (var fileName in fileEntries)
                {
                    if (fileName.EndsWith(".lnk"))
                    {
                        try
                        {
                            if (File.GetAttributes(IconGetter.GetExePathFromInk(fileName))
                                .HasFlag(FileAttributes.Directory))
                            {
                                lnkDir.Add(fileName);
                                continue;
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    }
                    parent.Append(new TreeNode <string>(parent, new List <TreeNode <string> >(), fileName.Replace("\\", "/")));
                }

                // Recurse into subdirectories of this directory.
                var subdirectoryEntries = new List <string>(Directory.GetDirectories(dir));
                subdirectoryEntries.AddRange(lnkDir);
                foreach (var subdirectory in subdirectoryEntries)
                {
                    var filtered = subdirectory.Replace("\\", "/");
                    var newNode  = new TreeNode <string>(parent, new List <TreeNode <string> >(), filtered);
                    parent.Append(newNode);
                    ProcessDirectory(filtered, newNode);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }