string x = txtpath.Text;
DirectoryInfo theFolder = new DirectoryInfo(x);
FileInfo[] fileInfo = theFolder.GetFiles();
foreach (FileInfo NextFile in fileInfo) //遍历文件
{
var filename = NextFile.Name;
}
原文:http://www.cnblogs.com/ft-Pavilion/p/4737603.html