void CModelDlg::FindBmpFile(CString strFoldername)
{
CString m_cstrFileList="";
CFileFind tempFind; BOOL bFound;
bFound=tempFind.FindFile(strFoldername + "\\*.bmp");
CString strTmp; while(bFound)
{
bFound=tempFind.FindNextFile(); if(!tempFind.IsDots())
{
if(tempFind.IsDirectory())
{
strTmp="";
strTmp=tempFind.GetFilePath();
FindBmpFile(strTmp);
}
else
{
strTmp=tempFind.GetFileName();
strTmp.MakeUpper(); if( strTmp.Right(4)==".BMP" )
{
m_cstrFileList+=tempFind.GetFilePath();
m_cstrFileList+=",";
}
}
}
} tempFind.Close(); return;
}
只能搜索当前文件夹下面的BMP文件。如果文件夹下面还有文件夹,就不能搜索到下一层的文件夹。为什么呀?怎么修改呢?
解决方案 »
- 如何用命令流的方式控制自己的软件。命令流可以自己定义,写程序让这个软件识别,命令流操作软件取代交互
- string作为message的wparam如何传递?
- 过年啦,散尽所有的分,^_^ --- 牛年快乐(下班前结帐,如果有时间,下午还有演讲,祝自己成功)
- 谁能在魔兽窗口上显示文字?
- 怎么用VC的单步调试功能进入窗口过程?
- bho能不能获得cookie或session的内容
- 急需office的接口函数库和说明!200分高分赠送
- 在WAV文件的语音数据中,有没有使用压缩算法,如果有,怎样解压缩?如果没有,那么是不是每个数据代表每次采样的值?
- 送分题:打开窗口的简单语句的问题:)
- VC数据库问题再问,出现Data Truncated!在线等待
- 如何用CBITMAP和CDC类,使得在CBITMAP上再画图
- 全屏录制功能问题(sdk)
{
m_cstrFileList+=tempFind.GetFilePath();
m_cstrFileList+=",";
}
你这对bmp做了判断了所以只能搜索bmp格式的,这个代码你去晚上搜索下有很多可以直接用的
{
struct _finddata_t ffblk;
char dirbuf[256];
char fname[256]; strcpy(dirbuf,directory);
strcat(dirbuf,"\\*.*");
long done = _findfirst(dirbuf,&ffblk);
int find=0;
while (find==0)
{
if (strcmp(ffblk.name, ".") && strcmp(ffblk.name, ".."))
{
strcpy(fname,directory);
strcat(fname,"\\");
strcat(fname,ffblk.name); if(isdir(ffblk.name))
ffind(fname);
else
printf("%s\n",fname);
}
find=_findnext(done,&ffblk);
}
_findclose(done);
}int isdir(char *directory)
{
if(strchr(directory,'.'))
return 0;
return 1;
}
你自己可以实现
{
....
fileFind.FindFile(strFoldername + "\\*.*");
...
if(找到的是目录) SearchFolder(strFindedFolderName);
if(找到的内容是BMP文件)
{
。
}
}
{
CString m_cstrFileList="";
CFileFind tempFind; BOOL bFound;
bFound=tempFind.FindFile(strFoldername + "\\*.bmp");
CString strTmp; while(bFound)
{
bFound=tempFind.FindNextFile();
//++++++++++++++++++++++++++++++++++++
if(tempFind.IsDots())
continue;
//+++++++++++++++++++++++++++++++++++
if(tempFind.IsDirectory())
{
strTmp="";
strTmp=tempFind.GetFilePath();
FindBmpFile(strTmp);
}
else
{
strTmp=tempFind.GetFileName();
strTmp.MakeUpper(); if( strTmp.Right(4)==".BMP" )
{
m_cstrFileList+=tempFind.GetFilePath();
m_cstrFileList+=",";
}
}
} tempFind.Close();
}不要把tempFind.IsDirectory()放在if(tempFind.IsDots())它的区域来判断