foreach (string item in Directory.GetFiles(dirPath, "*.htm"))
            {
//....
            }

  上面这段代码在.net 2.0里面是获取文件夹下所有.htm的文件。如果在.net 4.0里面用这段代码的同学注意了,以下是在使用4.0时MSDN说明:

例如,假设目录下有两个文件“file1.txt”和“file1.txtother”,使用“file?.txt”搜索模式时只返回第一个文件,而使用“file*.txt”搜索模式时会同时返回这两个文件。


解决方法:

 

foreach (string item in Directory.GetFiles(dirPath, "*").Where(file=>file.EndsWith("htm")).ToList())
            {
                
                m_works.Enqueue(item);
            }

 

至此完结...

 

关于GetFiles引发的一些事

 

 

相关文章:

  • 2021-12-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-28
  • 2022-12-23
  • 2021-10-13
猜你喜欢
  • 2021-10-10
  • 2022-03-08
  • 2021-06-03
  • 2021-09-09
  • 2021-06-08
  • 2021-04-09
  • 2022-12-23
相关资源
相似解决方案