コード例 #1
0
        //Trả về danh sách path thỏa mãn vào hàng đợi chứa 1 từ trong số các từ tìm kiếm
        public static void GetAll_BFS(Queue <string> queue_result, string root, string[] keyword, XFilter boloc)//tìm kiếm theo chiều rộng
        {
            Queue <string> pending = new Queue <string>();

            pending.Enqueue(root);
            while (pending.Count != 0)
            {
                var      path = pending.Dequeue();
                string[] next = null;
                try
                {
                    next = XFolder.GetDirectories(path).ToArray();              //lấy ra toàn bộ folder con
                    foreach (var subdir in next)
                    {
                        pending.Enqueue(subdir);                           //cho vào trong stackif (next != null) all += next.Count();
                    }
                }
                catch { }
                if (next != null)
                {
                    foreach (string item in next)                       //kiếm tra trong các folder tên có chứa chuối cần tìm
                    {
                        if (boloc.IsSatisfy(item) && XPath.IsEqualName(item, keyword))
                        {
                            queue_result.Enqueue(item);
                        }
                    }
                }
                try
                {
                    next = XFolder.GetFiles(path).ToArray();                    //lấy ra toàn bộ file trong folder đấy
                }
                catch { }
                if (next != null)
                {
                    foreach (string item in next)                       //kiếm tra trong các file tên có chứa chuối cần tìm
                    {
                        if (boloc.IsSatisfy(item) && XPath.IsEqualName(item, keyword))
                        {
                            queue_result.Enqueue(item);
                        }
                    }
                }
            }
        }
コード例 #2
0
        //trả về danh sách file trong thư mục có đường dẫn dirRoot vào List<treenode>
        public static List <TreeNode> LoadFile(string dirRoot)
        {
            List <TreeNode> listFile = new List <TreeNode>();

            try
            {
                string[] dirs = XFolder.GetFiles(dirRoot).ToArray();
                foreach (string dir in dirs)
                {
                    int           index = XImage.listIndex[(int)IndexImage.File];
                    DirectoryInfo di    = new DirectoryInfo(dir);
                    TreeNode      node  = new TreeNode(di.Name, index, index);
                    node.Tag = dir;
                    listFile.Add(node);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "DirectoryLister", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(listFile);
        }
コード例 #3
0
        //Trả về danh sách path thỏa mãn vào hàng đợi chứa 1 từ trong số các từ tìm kiếm
        public static void GetOne_BFS(Queue <string> queue_result, string root, string[] keyword, XFilter boloc)//tìm kiếm theo chiều rộng
        {
            var path = root;

            string[] next = null;
            try
            {
                next = XFolder.GetDirectories(path).ToArray();              //lấy ra toàn bộ folder con
            }
            catch { }
            if (next != null)
            {
                foreach (string item in next)                       //kiếm tra trong các folder tên có chứa chuối cần tìm
                {
                    if (boloc.IsSatisfy(item) && XPath.IsEqualName(item, keyword))
                    {
                        queue_result.Enqueue(item);
                    }
                }
            }
            try
            {
                next = XFolder.GetFiles(path).ToArray();                    //lấy ra toàn bộ file trong folder đấy
            }
            catch { }
            if (next != null)
            {
                foreach (string item in next)                       //kiếm tra trong các file tên có chứa chuối cần tìm
                {
                    if (boloc.IsSatisfy(item) && XPath.IsEqualName(item, keyword))
                    {
                        queue_result.Enqueue(item);
                    }
                }
            }
        }