关于从文件夹内读取所有txt文件时遇到的报错,请求一个解决方案。

我想写一段用于读取目录下所有文件的程序,都是根据文章里的内容按照我想要的效果改编而来,但是有一个错误一直无法修复。

switch(message)
{

        case IDM_ALL:
        {
            struct _finddata_t file;
            long handle;
            string path = classdesign.getinfile() + "\\*.txt";
            if ((handle = _findfirst(path.c_str(), &file)) == -1)
            {
                MessageBox(GetForegroundWindow(), L"目录下没有文本文件", L"间接平差", 1);
                break;
            }
            else
            {
                do
                {
                    classdesign.getdata(classdesign.getinfile() + "\\" + file.name);
                    classdesign.IndirectAdjustment();
                    classdesign.print(classdesign.getinfile() + "\\" + file.name);
                }while (!(_findnext(handle, &file)));
                _findclose(handle);
                MessageBox(GetForegroundWindow(), L"已完成目录下所有数据的平差", L"间接平差", 1);
            }
        }
  

}

运行时不会报错,但是会出现触发类似于未分配内存时的断点

img

我试过把这个循环内的三行代码全部注释掉,还是会有同样的报错。

这种情况发生是因为什么?
PS:设置里改过C++版本,改成了最新版。

要不忽略下这个异常试试?如果确定文章中的逻辑没错的话