标签:
0 探测的文件夹
1 代码
1 using System; 2 using System.Collections.Generic; 3 using System.IO; 4 using System.Linq; 5 using System.Text; 6 using System.Threading.Tasks; 7 8 namespace ConsoleApplication2 9 { 10 class Program 11 { 12 static void Main(string[] args) 13 { 14 //在指定路径下 15 string path = @"L:\"; 16 //文件夹的名字 17 string aFileName = "用程序创建的文件夹"; 18 19 //文件的绝对路径 20 string[] filePath = Directory.GetFiles(Path.Combine(path, aFileName)); 21 22 foreach (var item in filePath) 23 { 24 Console.WriteLine(Path.GetFileName(item)); 25 } 26 27 28 Console.ReadKey(); 29 } 30 } 31 }
2 效果
C#控制台基础 directory获取一个文件夹下所有文件的名字(不包含文件夹)
标签:
原文地址:http://www.cnblogs.com/jinlingzi/p/5963106.html