1个回答
展开全部
#include<iostream>
#include<windows.h>
using namespace std;
void func(LPTSTR fileName)
{
char sz[MAX_PATH];
lstrcpy(sz,fileName);
WIN32_FIND_DATA wfd;
HANDLE hFind;
TCHAR szF[MAX_PATH];
lstrcpy(szF,sz);
lstrcat(sz,"\\");
lstrcat(sz,"*.*");
hFind = FindFirstFile(sz,&wfd);
if(hFind == INVALID_HANDLE_VALUE)
return;
do
{
if(wfd.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
{
if(wfd.cFileName[0] == '.')
continue;
TCHAR szFn[MAX_PATH];
lstrcpy(szFn, szF);
lstrcat(szFn,"\\");
lstrcat(szFn,wfd.cFileName);
cout<<szFn<<endl;
func(szFn);
}
}while( FindNextFile(hFind,&wfd) );
}
void main()
{
TCHAR* sR[4] = {"C:","D:","E:","F:"};
for(int i=0; i<4; i++)
func( sR[i] );
cin.get();
}
#include<windows.h>
using namespace std;
void func(LPTSTR fileName)
{
char sz[MAX_PATH];
lstrcpy(sz,fileName);
WIN32_FIND_DATA wfd;
HANDLE hFind;
TCHAR szF[MAX_PATH];
lstrcpy(szF,sz);
lstrcat(sz,"\\");
lstrcat(sz,"*.*");
hFind = FindFirstFile(sz,&wfd);
if(hFind == INVALID_HANDLE_VALUE)
return;
do
{
if(wfd.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
{
if(wfd.cFileName[0] == '.')
continue;
TCHAR szFn[MAX_PATH];
lstrcpy(szFn, szF);
lstrcat(szFn,"\\");
lstrcat(szFn,wfd.cFileName);
cout<<szFn<<endl;
func(szFn);
}
}while( FindNextFile(hFind,&wfd) );
}
void main()
{
TCHAR* sR[4] = {"C:","D:","E:","F:"};
for(int i=0; i<4; i++)
func( sR[i] );
cin.get();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询