MFC 判断文件所在路径存在与否

1、头文件:shlwapi.h
2、链接库:Shlwapi.lib

#include 
#include 
using namespace std;
#pragma comment(lib,"Shlwapi.lib")

int main()
{
	string str = "E:\\Visual Studio 2013\\Projects\\test\\abc";
	if (PathFileExists(str.c_str()))
	{
		MessageBox(NULL, "存在", "", MB_OK);
	}
	else
	{
		MessageBox(NULL, "不存在,那就创建一个", "", MB_OK);
		CreateDirectory("E:\\Visual Studio 2013\\Projects\\test\\abc", NULL);
	}

	cin.get();
	return 0;
}

你可能感兴趣的:(MFC随笔)