16,472
社区成员
发帖
与我相关
我的任务
分享
#include <shlwapi.h>
#pragma comment(lib, "shlwapi.lib")
void Test()
{
TCHAR szFilePath[MAX_PATH + 1];
ZeroMemory(szFilePath, sizeof(szFilePath));
//获取APP路径
GetModuleFileName(NULL, szFilePath, MAX_PATH);
//去除APP文件名
PathRemoveFileSpec(szFilePath);
//添加目标文件名 (目标文件和App在同一目录下)
PathAppend(szFilePath, _T("Target.txt"));
TRACE(_T("File Path = [%s]\n"), szFilePath);
try
{
CFile f(szFilePath, CFile::modeRead);
f.Close();
}
catch(CFileException *e)
{
e->ReportError();
e->Delete();
}
}