之前的代码是这样写的:
CFileFind find;
find.FindFile("test");
CString strPath = find.GetFilePath();
结果程序就中断了。
原来:
在MSDN中是这样说的Call this member function to open a file search.After calling FindFile to begin the file search, call FindNextFile to retrieve subsequent files. You must call FindNextFile at least once before calling any of the following attribute member functionsGetCreationTimeGetFileNameGetFileTitleGetFilePathGetFileURLGetLastAccessTimeGetLastWriteTimeGetLengthGetRoot
所以代码应该改成:
CFileFind find;
find.FindFile("test");
find.FindNextFile();
CString strPath = find.GetFilePath();
当然根据自己的需要可以判断一下这些find函数的返回值。
使用CFileFind 时发生ASSERT
最新推荐文章于 2019-01-23 19:43:50 发布