選擇資料夾,獲取資料夾裡的所有檔案

2022-02-08 01:07:03 字數 731 閱讀 7975

點選文字框,選擇資料夾,點選確定

下面我們用**來實現:

首先,我們寫乙個函式,用遞迴的方法實現迴圈遍歷,找到資料夾裡所有的檔案(此處以xml為例)

private

static list replacetextinrecursivedir(string path, bool

bsearchchilddir)

}if (bsearchchilddir == true

)

}return

filelist;

}

建立文字框的點選事件

private

void textbox1_click(object

sender, eventargs e)

//把路徑寫在文字框上

textbox1.text =dialog.selectedpath;

filelist = replacetextinrecursivedir(dialog.selectedpath, true

); }

}

上段**中 filelist 是乙個static變數

static list filelist = new list();
老鐵,希望可以幫到!!!

python 統計資料夾下的所有資料夾或檔案數目

統計 home jiangt下資料夾的個數 import os path home jiangt count 0 for file in os.listdir path file 表示的是檔名 count count 1 print count獲取資料夾下的檔案的個數 import os path ...

C 獲取資料夾中所有檔案

獲取資料夾中的檔案,用到過很多次,每次用的時候都要去查下,很煩,所以想自己寫下,當然,借鑑了很多其他大佬的部落格 主要實現的函式,如下 1 void getfiles string path,vector files 2 19else 20 23 while findnext hfile,filei...

VC 讀取資料夾裡面的資料夾名

參考書裡面的寫法。同學指導,c 一點也不會啊!繼續努力 define win32 winnt 0x0400 include windows.h include int findfilename lpctstr filepath void main int findfilename lpctstr f...