struct _finddata_t c_file
long hFile
if( (hFile = _findfirst( LPCTSTR(pathWild), &c_file )) == -1L)
{
MessageBox("选择目录拦睁下并无doc文件,请歼轮确认")
_findclose(hFile)
return
}
else
{
do
{
//这里就是文件名,加上之前的路径就是完整路径了
CString strFileName = c_file.name
//下面就是将strFileName打印出来即氏衡信可
}
while (_findnext(hFile, &c_file) == 0)
}
_findclose(hFile)
递归获和坦燃取信慧本文件夹(包括子文件夹)中的文件:int CountDirectory(CString path)
{
int count = 0
CFileFind finder
BOOL working = finder.FindFile(path + "\\唤虚*.*")
while (working)
{
working = finder.FindNextFile()
if (finder.IsDots())
continue
if (finder.IsDirectory())
count += CountDirectory(finder.GetFilePath())
else
count++
}
return count
}
只获取本文件夹中的文件:
int CountDirectory(CString path)
{
int count = 0
CFileFind finder
BOOL working = finder.FindFile(path + "\\*.*")
while (working)
{
working = finder.FindNextFile()
if (finder.IsDots())
continue
if (!finder.IsDirectory())
count++
}
return count
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)