关于VC++ MFC 中CFileFind类的问题

来源:百度知道 编辑:UC知道 时间:2024/06/06 07:19:31
我简单写了个函数,用来检测是否存在autorun.inf文件,但是发现如果当前目录下没有autorun.inf文件的话,它显示正常,但如果存在的话,会报错,标题是“Microsoft Visual C++ Debug Library”,错误界面如图,点击忽略后也会能正确显示,请问问题出在哪儿了呢??还有就是该如何指定CFileFind对象所搜索的具体路径呢?比如我要搜C盘??谢谢大家

void CMy000Dlg::scanqq()
{ CFileFind ffind;
CString str;
if(!ffind.FindFile("autorun.inf"))
m_text1.SetWindowText("未找到文件");
else {m_text1.SetWindowText("发现目标文件");
str=ffind.GetFilePath();
m_text2.SetWindowText(str);
}
ffind.Close();
}

Call this member function to get the name of the found file. You must call
FindNextFile
at least once before calling GetFilePath.

你把你的编译改成Release试试看。如果还是那样,你就放断点,单步调一下。
路径你说想指定具体的。说真的没太明白,我见意你放一个EDIT控件,和一个按钮。添加打开对话框,把打开的文件名去掉,就是具体路径名称,把路径名称显示在EDIT上。这样就成了一个活的路径了。眼前只想到这。