Directory.GetFiles有多个过滤器? [英] Multiple filters with Directory.GetFiles?

查看:252
本文介绍了Directory.GetFiles有多个过滤器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过Directory.GetFiles()命令使用多个过滤器.

I'm trying to use multiple filters with the Directory.GetFiles() command.

所以说我想同时匹配.html和.css文件.我正在使用这个:

So say I want to match both .html and .css files. I'm using this:

Directory.GetFiles(path,"*.html|*.css");

我没有看到任何文档,但该文档支持该文档,最终它与HTML或CSS文件都不匹配.有什么我想念的吗?

I don't see any documentation however that this is supported, and it ends up not matching either HTML or CSS files. Is there something I'm missing?

推荐答案

Directory.GetFiles函数不支持多个过滤器.我的解决方案:

The Directory.GetFiles function doesn't support multiple filters. My solution:

string patter = "*.jpg|*.png|*.gif";
string[] filters = patter.Split('|');
foreach(string filter in filters )
{
  // call Directory.GetFiles(path, filter) here;
}

这篇关于Directory.GetFiles有多个过滤器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆