简体   繁体   English

C ++如何使用带有多个通配符的路径查找文件

[英]C++ How to Find Files Using Path With Multiple Wildcards

I want of find files using search paths such as: 我想要使​​用搜索路径查找文件,例如:

C:\Users\*\AppData\*\Temp\f?le.*

I am using Windows so I cannot us the glob.h header. 我正在使用Windows,所以无法使用glob.h标头。 I have used the Windows API function PathMatchSpec, but it only allows wildcards in the last part of the path (f?le.*). 我已经使用了Windows API函数PathMatchSpec,但它仅在路径的最后一部分(文件*)中允许使用通配符。 Is there anything I can do? 有什么我可以做的吗?

PS Please correct me if I am breaking any SO rules--I'm new to this site. PS:如果我违反任何SO规则,请纠正我-我是该网站的新手。

You can use boost::filesystem. 您可以使用boost :: filesystem。 here a link to the library: http://www.boost.org/doc/libs/1_57_0/libs/filesystem/doc/index.htm 这里是库的链接: http : //www.boost.org/doc/libs/1_57_0/libs/filesystem/doc/index.htm

you can iterate on a path. 您可以在路径上进行迭代。 You can declare a regular expression boost::regexp and pass it to the boost::filesystem::path. 您可以声明一个正则表达式boost :: regexp并将其传递给boost :: filesystem :: path。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM