using System.IO; namespace 获取文件夹和文件路径 { class Program { static void Main(string[] args) { string[] filePath = Directory.GetFiles(@"D:\123");//文件路径 string[] dirPath =Directory.GetDirectories(@"D:\123");//文件夹路径 foreach (string fies in filePath) { Console.WriteLine(fies); } foreach (string dir in dirPath) { Console.WriteLine(dir); } Console.ReadKey(); } } }
浙公网安备 33010602011771号