void CCISSQLDBDlg::FindMyFile(CString FilePath,CString FileFormat,CStringArray& arrFilePath,CStringArray& arrName)
{
BOOL bFind, bFindSuffix;
CFileFind tempFind, tempFind1; //定义文件查找类型变量
_chdir(FilePath);
bFind=tempFind.FindFile(_T("*.*"));//如果所在目录下有*.*文件返回1,如果没有就返回0
while(bFind) //访问1进入循环
{
bFind = tempFind.FindNextFile(); //查找下一个文件
if(tempFind.IsDirectory()) //如果tempFind是目录
{
if(!tempFind.IsDots()) //判断tempFind下面是否还有子目录
{
CString tempFindPath;
tempFindPath=tempFind.GetFilePath(); //查找文件所在的路径
FindMyFile(tempFindPath,FileFormat,arrFilePath,arrName);//递归函数
}
}
}
_chdir(FilePath);
bFindSuffix=tempFind1.FindFile(_T("*.*"));
while(bFindSuffix)
{
bFindSuffix = tempFind1.FindNextFile();
CString strFilePath, strFileName;
if ( !tempFind1.IsDirectory() && !tempFind1.IsDots() )
{
strFilePath = tempFind1.GetFilePath();
strFileName = tempFind1.GetFileName();
strFileName.MakeUpper();
FileFormat.MakeUpper();
if(strFileName.Right(3)== FileFormat&&strFileName.Left(1)!="~")//判断文件.右边3个字符等于指定的为扩展名并且文件前面无~
{
arrFilePath.Add(strFilePath); //将该文件的绝对路径保存到arrFilePath数组中
arrName.Add(strFileName); //将该文件的名字保存到arrName数组中
}
}
}
tempFind.Close();
tempFind1.Close();
}
{
BOOL bFind, bFindSuffix;
CFileFind tempFind, tempFind1; //定义文件查找类型变量
_chdir(FilePath);
bFind=tempFind.FindFile(_T("*.*"));//如果所在目录下有*.*文件返回1,如果没有就返回0
while(bFind) //访问1进入循环
{
bFind = tempFind.FindNextFile(); //查找下一个文件
if(tempFind.IsDirectory()) //如果tempFind是目录
{
if(!tempFind.IsDots()) //判断tempFind下面是否还有子目录
{
CString tempFindPath;
tempFindPath=tempFind.GetFilePath(); //查找文件所在的路径
FindMyFile(tempFindPath,FileFormat,arrFilePath,arrName);//递归函数
}
}
}
_chdir(FilePath);
bFindSuffix=tempFind1.FindFile(_T("*.*"));
while(bFindSuffix)
{
bFindSuffix = tempFind1.FindNextFile();
CString strFilePath, strFileName;
if ( !tempFind1.IsDirectory() && !tempFind1.IsDots() )
{
strFilePath = tempFind1.GetFilePath();
strFileName = tempFind1.GetFileName();
strFileName.MakeUpper();
FileFormat.MakeUpper();
if(strFileName.Right(3)== FileFormat&&strFileName.Left(1)!="~")//判断文件.右边3个字符等于指定的为扩展名并且文件前面无~
{
arrFilePath.Add(strFilePath); //将该文件的绝对路径保存到arrFilePath数组中
arrName.Add(strFileName); //将该文件的名字保存到arrName数组中
}
}
}
tempFind.Close();
tempFind1.Close();
}