#include <stdio.h>
#include <io.h>
#include <string>
#include<fstream>
using namespace std;
int main()
{
//目标文件夹路径
std::string inPath = "F:\\*.mp3";//遍历文件夹下的所有.MP3文件,支持输入路径,支持通配符*等
ofstream outfile("F:\\out.txt", ios::app); //写追加模式,路径与名字可以自定义 //用于查找的句柄
intptr_t handle;
struct _finddata_t fileinfo;
//第一次查找
handle = _findfirst(inPath.c_str(), &fileinfo);
if (handle == -1)
return -1;
do
{
//找到的文件的文件名
printf("%s\n", fileinfo.name);
outfile << fileinfo.name;
outfile << endl;
} while (!_findnext(handle, &fileinfo));
_findclose(handle);
system("pause");
return 0;
}
08-03
1176