C++递归遍历文件目录,编译成功 但控制台却不显示任何数据,还请高手指教!
代码如下:// KZT1.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
#include <stdio.h>
#include <io.h>
#include <string>
using namespace std;
void dfsFolder(string folderPath)
{
_finddata_t Fileinfo;
string search = folderPath+"\\*";
intptr_t Handle = _findfirst(search.c_str(),&Fileinfo);
if (Handle==-1L)
{
printf("无法找到相应路径\n");
exit(0);
}
do
{
if (Fileinfo.attrib&_A_SUBDIR)
{
if (strcmp(Fileinfo.name,".")!=0&&strcmp(Fileinfo.name,".."))
{
string newpath=folderPath+""+Fileinfo.name;
dfsFolder(newpath);
}
}
else
{
cout<<folderPath+"\\"<<Fileinfo.name<<endl;
printf("%s\\%s\n",folderPath,Fileinfo.name);
}
}
while (_findnext(Handle,&Fileinfo));
{
_findclose(Handle);
}
}
int _tmain(int argc, _TCHAR* argv[])
{
string path = "F:\\电影\\西游记";//
dfsFolder(path);
int i ;
cin>>i;
return 0;
}