我看了下FindFirstFile(), 它传回的好象是传入进去的那个文件.想问一下在不知道文件夹下的任何文件名时,怎么遍历其中所有的文件?
谢谢!
解决方案 »
- 如何实现获得对方(客户端)的ip和port
- 像浩方这样的平台算不算是“外、挂”?
- 工具条重写MouseHover//rc.right=rc.left+8;是什么作用呢?
- 请问如何把画在位图上线添加到该位图文件中?
- cximage问题
- 大家讨论:多画面视频监控的实现
- 请问点对点通信的方式
- 在stl的list中如何定义它的元素为已知的结构体?高分送上
- 请问在GSM模块发送短信的程序中,中文用Unicode,可是发送到手机上为什么会出现乱码呢?
- 此语句如何解?
- 请教一个关于WINDOWS内幕的问题,HINSTANCE在内存中应该是一个数据结构吧,它的数据结构原型是什么?
- ~~~怎么在托盘区显示256色以上的图标?~~~
{
CFileFind ff;
BOOL bFound;
bFound = ff.FindFile(sPath + "\\*.*");//找第一个文件
while(bFound)//如果找到,继续
{
bFound = ff.FindNextFile();
CString sFilePath = ff.GetFilePath(); if(ff.IsDirectory())//如果是目录,注意任何一个目录都包括.和..目录
{
if(!ff.IsDots())//去除.和..目录
ListFolder(sFilePath);//递归下一层目录
} else {
AfxMessageBox(sFilePath);//枚举到的文件名字
}
}
ff.Close();
}
const char strDir[] = "F:\\files\\";
char strFileName[MAX_PATH];
WIN32_FIND_DATAA fd;strcpy( strFileName, strDir );
strcat( strFileName, "*.*" );
g_hFindFile = ::FindFirstFile( strFileName, &fd );
while( FindNextFile( g_hFindFile, &fd ) )
{
fd包含文件(或文件夹)属性
}
就方法就解决了.
要是文件层数太多,文件数量过大,小心你的堆栈溢出就行了.
HTREEITEM temChildItem;
while(temFatherItem)
{
temChildItem=m_msgTree.GetChildItem(temFatherItem);
if(temChildItem)
{
generalNod_T *pNod_T = (generalNod_T *)m_msgTree.GetItemData(temChildItem);
delete pNod_T;
pNod_T=NULL;
while(temChildItem)
{
temChildItem=m_msgTree.GetNextSiblingItem(temChildItem);
if(temChildItem)
{
pNod_T = (generalNod_T *)m_msgTree.GetItemData(temChildItem);
delete pNod_T;
pNod_T=NULL;
}
}
}
temFatherItem=m_msgTree.GetNextSiblingItem(temFatherItem);
}