1. 程式人生 > 其它 >.Net System.IO 獲取資料夾下所有子資料夾名及目錄

.Net System.IO 獲取資料夾下所有子資料夾名及目錄

技術標籤:C#c#

.Net System.IO 獲取資料夾下所有子資料夾名及目錄

			//獲取path下所有的資料夾
            System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(path);
            System.IO.DirectoryInfo[] folders = dir.GetDirectories();
            //獲取資料夾名
            string[] folderName = new string[folders.Length];
            string
[] folderPath = new string[folders.Length]; int leng = 0; foreach (System.IO.DirectoryInfo item in folders) { //獲取資料夾名 folderName[leng] = item.Name; //獲取子目錄路徑 folderPath[leng] = path + @"\" + item.Name;
leng++; }