用foreach遍历所有文件,找出包含p字符的文件名,但foreach不运行,
static void Main(string[] args)
{
string path = @"D:\itcast\chapter08\progrom04\bin\Debug\Test";
DirectoryInfo di = new DirectoryInfo(path);
di.Create();
Console.WriteLine("当前的目录名为:" +di.Name);
string path1 = @"D:\itcast\chapter08\progrom04\bin\Debug";
DirectoryInfo dil = new DirectoryInfo(path1);
FileInfo[] Files = dil.GetFiles("*p*");
foreach (FileInfo item in Files)
{
Console.WriteLine("包含p字符的文件名称为:" + dil.Name);
}
Console.ReadKey();
一起编程
2015/08/01 09:48- c#
- 点赞
- 收藏
- 回答