开发者

dirInfoObj.GetFiles("*.jpg,*.png") does not return any files

开发者 https://www.devze.com 2023-01-24 01:42 出处:网络
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

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

开发者_Python百科dirInfoObj.GetFiles("*.jpg,*.png")

, it won't return anything.

Am I doing something wrong? Thanks!


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消