#include <stdio.h>
#include <Windows.h>
using namespace std;
void FindFile(const char* filename)//函数语句:找出全盘文件
{
char tempPath[1000] = { 0 };
sprintf(tempPath, "%s\\*.*", filename);
WIN32_FIND_DATA finddata;//文件属性
HANDLE hfile = FindFirstFile(tempPath, &finddata);
while (1)
{
if (finddata.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)//文件夹
{
if (finddata.cFileName[0] != '.')
{
sprintf(tempPath, "%s\\%s", filename, finddata.cFileName);
printf("%s——————————————————\n", tempPath);
FindFile(tempPath);
}
}
else//文件
{
sprintf(tempPath, "%s\\%s", filename, finddata.cFileName);
printf("%s****************此处不读\n", tempPath);
}
if (FindNextFile(hfile, &finddata) == 0)
break;
}
}
int main()
{
char path[5] = { 0 };
unsigned alldisk;
printf("主人:\n正在为您检测U盘的拔插喵喵喵喵喵喵。。。。。。\n");
while(1)
{
alldisk = GetLogicalDrives();
for (int i = 0; i < 10; i++)
{
if ((alldisk & 1) == 1)
{
sprintf(path, "%c:", 'A' + i);
}
alldisk = alldisk >> 1;
}
if (GetDriveType(path) == DRIVE_REMOVABLE)
break;
}
printf("主人:\nU盘:%s已经插入喵", path);
FindFile("F:\Documents");
return 0;
}
一:

文件夹Documents中存在文件,不读取其中的文件。
二:


读取study文件夹里面的文件,但是不读取videos里面的文件。
求求大佬解答