标签:
class Program { static List<string> allFileName=new List<string>(); static void Main(string[] args) { string[] drives = Directory.GetLogicalDrives(); foreach (string drive in drives) { getAll(drive); } } static void getAll(string path) { DirectoryInfo sDir = new DirectoryInfo(path); try { FileInfo[] fileArray = sDir.GetFiles(); foreach (FileInfo file in fileArray) { allFileName.Add(file.FullName); } } catch(Exception e) { } try { DirectoryInfo[] subDirArray = sDir.GetDirectories(); foreach (DirectoryInfo subDir in subDirArray) { getAll(subDir.FullName); } } catch (Exception e) { } } }
标签:
原文地址:http://www.cnblogs.com/rinack/p/4623910.html