您可以使用 FindFirstFile 和 FindNextFile 用于遍历目录的函数.前缀可以包含在搜索词中. 示例 std::string strSearch = "C:\\Some Directory\\Bob*";WIN32_FIND_DATAA ffd;HANDLE hFind = FindFirstFileA(strSearch .c_str(), &ffd);do{ std::string strFile = ffd.cFileName;}while (FindNextFileA(hFind, &ffd) != 0); 正确的错误检查以及如何处理目录留给读者练习. I wonder how to check If a file exist or not :For Example I have many files : Boba.txtJames.txtJamy.txtBoby.txtHow can I check if the file starting with Bob exists ? 解决方案 Note, I'm assuming that you're on a Windows system and that the files are in the same directory.You can use the FindFirstFile and FindNextFile functions to iterate through a directory. The prefix can be included in search term.Examplestd::string strSearch = "C:\\Some Directory\\Bob*";WIN32_FIND_DATAA ffd;HANDLE hFind = FindFirstFileA(strSearch .c_str(), &ffd);do{ std::string strFile = ffd.cFileName;}while (FindNextFileA(hFind, &ffd) != 0);Proper error checking and how to deal with directories is left as an exercise for the reader. 这篇关于查找以特定字符串开头的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-31 09:31