使用 Directory.GetFiles 进行多个过滤器?
我正在尝试通过 Directory.GetFiles() 命令使用多个过滤器。
假设我想匹配 .html 和 .css 文件。我正在使用这个:
Directory.GetFiles(path,"*.html|*.css");
我没有看到任何文档表明这是受支持的,并且它最终与 HTML 或 CSS 文件不匹配。我有什么遗漏的吗?
I'm trying to use multiple filters with the Directory.GetFiles() command.
So say I want to match both .html and .css files. I'm using this:
Directory.GetFiles(path,"*.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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Directory.GetFiles 函数不支持多个筛选器。我的解决方案:
The Directory.GetFiles function doesn't support multiple filters. My solution:
还有一个下降解决方案可以避免 foreach 循环(在 Linq 的帮助下):
There is also a descent solution which avoids foreach loops (with the help of Linq):