从目录获取文件时排除某些文件扩展名
从目录获取文件时如何排除某些文件类型?
我试过了
var files = Directory.GetFiles(jobDir);
,但好像这个功能只能选择你想要包含的文件类型,不能排除。
How to exclude certain file type when getting files from a directory?
I tried
var files = Directory.GetFiles(jobDir);
But it seems that this function can only choose the file types you want to include, not exclude.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
如果您想排除文件扩展名列表:(基于 https://stackoverflow.com/a/19961761/1970301 )
if you want exlude a list of file extension: (based on https://stackoverflow.com/a/19961761/1970301)
你可以尝试这样的事情:
You could try something like this:
我想你可以使用 lambda 表达式
I guess you can use lambda expression
你可以试试这个,
You can try this,
据我所知,没有办法指定排除模式。
您必须手动执行此操作,例如:
Afaik there is no way to specify the exclude patterns.
You have to do it manually, like:
这是我在上面读到的答案的版本
This is my version on the answers I read above
我遇到了这个问题,正在寻找一种方法来执行此操作,其中排除可以使用搜索模式规则而不仅仅是 EndWith 类型逻辑。
例如,搜索模式通配符说明符匹配:
这可以用于上述用途,如下所示。
或者排除本来会包含的项目。
I came across this looking for a method to do this where the exclusion could use the search pattern rules and not just EndWith type logic.
e.g. Search pattern wildcard specifier matches:
This could be used for the above as follows.
Or to exclude items that would otherwise be included.
我用过那个
且 PATH 为:
i used that
and the PATH is:
你应该自己过滤这些文件,你可以这样写:
You should filter these files yourself, you can write something like this: