C++扫描目录下文件,可以根据后缀名扫描,可以用通配符的方式扫描,可以显示文件属性(只读,隐藏,类型等)。
        所用函数:
      long _findfirst( char *filespec, struct _finddata_t *fileinfo );
代码示例:
#include<iostream>
#include<io.h>
using namespace std;
 
int main()
{
    _finddata_t file;
    long lf;
    if((lf=_findfirst("*.txt",&file))==-1)
    {
        cout<<"can not find file"<<endl;
    }
    else
    {
        do
        {
            cout<<file.name<<endl;
        }while(_findnext(lf,&file)==0);
        
        
        
    }
    return 0;
}
————————————————
原文链接:https://blog.csdn.net/jiangjianant/article/details/21409109
如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!
 支付宝打赏
支付宝打赏
      微信打赏
微信打赏
     
txttool.com 说一段 esp56物联 查询128 IP查询