示例#1
0
        //hàm tạo các phần tử miêu tả nội dung của thư mục strDir
        private void ExploreDir(String strDir, TreeNode hParent)
        {
            String strSearchDir;
            String strsubDir;

            strSearchDir = strDir + "\\*";
            FindData fd    = new FindData();
            IntPtr   hFile = MyFileFind.FindFirstFile(strSearchDir, fd);

            if (hFile == (IntPtr)(-1))
            {
                // the directory is empty; just close up and return.
                return;
            }

            TreeNode hThisItem;
            String   strFileName;
            Boolean  bContinue = true;

            while (bContinue)
            {// thêm từng phần tử trong thư mục hiện hành vào vị trí tương ứng của TreeView
                strFileName = fd.fileName;
                if (strFileName != "." && strFileName != "..")
                {
                    hThisItem = hParent.Nodes.Add(strFileName);
                    if ((fd.fileAttributes & 0x10) != 0)
                    {
                        strsubDir = strDir + "\\" + strFileName;
                        ExploreDir(strsubDir, hThisItem);
                    }
                }
                bContinue = MyFileFind.FindNextFile(hFile, fd);
            }
            return;
        }
示例#2
0
 public static extern Boolean FindNextFile(IntPtr handle, [In, Out] FindData findFileData);
示例#3
0
 public static extern IntPtr FindFirstFile(String fileName, [In, Out] FindData findFileData);