CString strFindFile;
strFindFile.Format(_T("%\\*.xml"), strPath);
CFileFind finder;
BOOL bWorking = finder.FindFile(strFindFile);
while (bWorking)
{
bWorking = finder.FindNextFile();
CString strFile = finder.GetFilePath();
//printf( strFile );
}
转载于:http://blog.163.com/wslngcjsdxdr@126/blog/static/1621962302012319540460/
#include "windows.h"
#include "stdio.h"
#include <Shlobj.h>
void
delallfile(
char
*Path)
{
char
file[MAX_PATH];
lstrcpy(file,Path);
lstrcat(file,
"\\*.*"
);
WIN32_FIND_DATA wfd;
HANDLE
Find = FindFirstFile(file,&wfd);
if
(Find == INVALID_HANDLE_VALUE)
return
;
while
(1)
{
if
(wfd.cFileName[0] ==
'.'
)
{
continue
;
}
if
(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
char
szFindPath[MAX_PATH];
lstrcpy(szFindPath,Path);
lstrcat(szFindPath,
"\\"
);
lstrcat(szFindPath,wfd.cFileName);
delallfile(szFindPath);
}
char
FilePath[MAX_PATH];
lstrcpy(FilePath,Path);
lstrcat(FilePath,
"\\"
);
lstrcat(FilePath,wfd.cFileName);
printf
(
"%s\r\n"
,FilePath);
//DeleteFile(FilePath);
//这里写上你要执行的操作
if(!FindNextFile(Find, &wfd))
break;
}
FindClose(Find);
}
摘自CSDN论坛:http://bbs.csdn.net/topics/110066611