使用CFileFind::GetLength()(代码最后一部分)得到的所有搜索到的文件的大小都是0,结果如图,不知道错在哪,
DWORD CFFDlg::FileTraverInDir(LPSTR szPath)
{
CFileFind ff;
CString str1;
CString str2;
int ret=ff.FindFile(szPath,0);
if(!ret)
{
str1.Format(str1,"%s下没有文件",szPath);
AfxMessageBox(str1);
return 0;
}
//获取文件的属性:文件名,大小,修改时间,文件类型和修改时间
ret=ff.FindNextFile();//必须呼叫这个之后才能呼叫其他获取属性的函数
do
{
//获取文件名
str1=ff.GetFileName();
::MessageBox(NULL,str1,"文件名",MB_OK);
//获取文件创建时间
FILETIME ft;
ff.GetCreationTime(&ft);
CTime refTime(ft);
str1.Format("%4d年%2d月%2d日 %2d:%2d:%2d",
refTime.GetYear(),refTime.GetMonth(),refTime.GetDay(),
refTime.GetHour(),refTime.GetMinute(),refTime.GetSecond());
// ::MessageBox(NULL,str1,"文件创建时间",0);
//获取文件大小
**ULONGLONG length;
length=ff.GetLength();
TRACE("%I64u byte(s)",length);
// str1.Format("%I64u byte(s)",length);
// ::MessageBox(NULL,str1,"文件大小",0);
**
}while(ff.FindNextFile());//为0说明文件已到最后
return TRUE;
}