很奇怪的错误,明明文件存在,而且debug显示路径正确却总是打开失败

BestSky BestSky 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
TCHAR exeFullPath[MAX_PATH];
CString strPath;
//得到运行的exe路径
GetModuleFileName(NULL,exeFullPath,MAX_PATH);
strPath=(CString)exeFullPath;
int position=strPath.ReverseFind('\\');
strPath=strPath.Left(position);
position = strPath.ReverseFind('\\');
strPath = strPath.Left(position+1);
//以上是取得了工程的路径
std::string fName = strPath;
//工程路径加上相对路径
strTrainFile = fName.append(strTrainFile);
std::ifstream inFile(strTrainFile.c_str());
if( inFile.fail() )
{
return false;
}
在工程中有个文件,在trainData\matrixFeature.txt中.
我现在首先取得工程的路径(strPath),然后添加相对路径(trainData\matrixFeature.txt),经过查看,strTrainFile确实是正确的路径,但是就是每次打开都失败,高手看看为什么吧,谢谢.
...全文

相关推荐

评论 9
收藏 已收藏
分享
返回顶部
BestSky
VC/MFC 16,550 成员 421,606 内容