现在的位置: 首页 > 综合 > 正文

c++读取文件夹下的所有文件名

2013年12月02日 ⁄ 综合 ⁄ 共 285字 ⁄ 字号 评论关闭

#include<iostream>
#include<io.h>
using namespace std;
int main(){
    _finddata_t file;
    long lf;
    //输入文件夹路径
    if((lf = _findfirst("d:\\OSG\\Data\\*.*", &file))==-1)
        cout<<"Not Found!"<<endl;
    else{
        //输出文件名
        cout<<"file name list:"<<endl;
        while(_findnext( lf, &file)==0){
            cout<<file.name<<endl;
        }
    }
    _findclose(lf);
    return 0;
}

抱歉!评论已关闭.