[求助]如何获取指定目录下指定类型文件名到一个字符串数组中?
rt
搞定了,贴上来大家一起分享
HANDLE hFindFile;
WIN32_FIND_DATA FindData;
CString fileName;
hFindFile = FindFirstFile("data\\scenedata\\*.txt", &FindData);
if(hFindFile == INVALID_HANDLE_VALUE) return;
if(FindData.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY){
fileName = FindData.cFileName;
int k = fileName.Find(".txt");
m_SceneData.Clear();
m_SceneData.AddString(fileName.Left(k));
}
while(FindNextFile(hFindFile,&FindData)){
if(FindData.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY){
fileName = FindData.cFileName;
int k = fileName.Find(".txt");
m_SceneData.AddString(fileName.Left(k));
}
}
FindClose(hFindFile);
注:m_SceneData是CComboBox