dirInfoObj.GetFiles("*.jpg,*.png") 不返回任何文件

发布于 2024-10-01 10:06:58 字数 223 浏览 2 评论 0 原文

如果我简单地这样做

dirInfoObj.GetFiles("*.jpg")

,它将返回我在那里的 2 张 jpg。但如果我尝试同时获取 jpg 和 png,例如

dirInfoObj.GetFiles("*.jpg,*.png")

,它不会返回任何内容。

我做错了什么吗?谢谢!

If I do simply

dirInfoObj.GetFiles("*.jpg")

, it will return the 2 jpg's I have there. But if I try and get both jpg's and png's, like

dirInfoObj.GetFiles("*.jpg,*.png")

, it won't return anything.

Am I doing something wrong? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

愁杀 2024-10-08 10:06:58

GetFiles 的文档中没有任何内容表明它支持使用 , 字符,就像您的意思一样。如果您使用 LINQ,您可以执行以下操作:

var files = dirInfoObj.GetFiles("*.jpg").Concat(dirInfoObj.GetFiles("*.png"));

如果您需要 files 作为数组,只需在末尾抛出一个 .ToArray() 即可。

There is nothing in the documentation for GetFiles that indicates that it supports usage of the , character like you mean it. If you are using LINQ, you could do something like:

var files = dirInfoObj.GetFiles("*.jpg").Concat(dirInfoObj.GetFiles("*.png"));

If you need files to be an array, just throw a .ToArray() on the end.

青丝拂面 2024-10-08 10:06:58

GetFiles 上的 MSDN 条目

http://msdn.microsoft.com/en-us/ Library/8he88b63.aspx

说明了如何使用它。

它不支持多个扩展名的逗号运算符。

The MSDN entry on GetFiles

http://msdn.microsoft.com/en-us/library/8he88b63.aspx

states how it can be used.

It does not support a comma operator for multiple extensions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文