米度软件:www.midosoft.cn
typedef CList<long,long> LongList;
typedef CList<CString,CString&> StringList;
int GetFileList(CString path,CString ext,LongList& sizelist,StringList& namelist)
{
CString FileName;
WIN32_FIND_DATA fdata = {0};
BOOL bFinished = FALSE;
int nIndex = 0;
FileName = path + "*." + ext;
HANDLE hSearch = FindFirstFile(FileName.GetBuffer(0),&fdata);
if(hSearch == INVALID_HANDLE_VALUE)
return 0;
while(!bFinished)
{
if(!(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
if (nIndex==0)
{
sizelist.AddHead((long)fdata.nFileSizeLow);
FileName.Format("%s%s",path,fdata.cFileName);
namelist.AddHead(FileName);
}
else
{
POSITION pos;
pos = sizelist.FindIndex(nIndex);
sizelist.InsertAfter(pos,(long)fdata.nFileSizeLow);
pos = namelist.FindIndex(nIndex);
FileName.Format("%s%s",path,fdata.cFileName);
namelist.InsertAfter(pos,FileName);
}
nIndex++;
}
if(!FindNextFile(hSearch, &fdata))
{
if (GetLastError() == ERROR_NO_MORE_FILES)
bFinished = TRUE;
}
}
FindClose(hSearch);
return nIndex;
米度软件:www.midosoft.cn