如何在MFC(VC++)中检查目录是否已经存在? 我正在使用以下代码获取当前应用程序路径并创建NDSLog文件夹,以便将所有日志文件放置在那里,现在我想检查条件,如果NDSLog文件夹已经存在,则不要创建它。如何实现?
谢谢。
char strPathName[_MAX_PATH];
::GetModuleFileName(NULL, strPathName, _MAX_PATH);
// The following code will allow you to get the path.
CString newPath(strPathName);
int fpos = newPath.ReverseFind('\\');
if (fpos != -1)
newPath = newPath.Left(fpos+1);
newPath += "NDSLog\\" ;
CreateDirectory(newPath,NULL);