static void Main(string[] args)
        {
        	//获取磁盘名称
            string[] a = Environment.GetLogicalDrives();
			//循环输出
            foreach (var item in a)
            {
                Console.WriteLine(item);
				
				//通过磁盘名称获取其子目录
                DirectoryInfo di = new DirectoryInfo(item);
                DirectoryInfo[] fi = di.GetDirectories();
				//循环输出
                foreach (var i in fi)
                {
                    Console.WriteLine(i);
                }
            }
            Console.ReadKey();
        }
posted on 2019-11-18 14:55  .net之路  阅读(94)  评论(0编辑  收藏  举报