MFC工控项目实例之四在调试目录下创建指定文件夹

承接专栏《MFC工控项目实例之三theApp变量传递对话框参数》

在调试目录Debug下创建DATA、LIB、TEMP三个文件夹

1、SEAL_PRESSURE.h中添加代码

cpp 复制代码
class CSeatApp : public CWinApp
{
...
public:
	CString	m_Path;
	CString	m_DataPath,m_TempPath,m_LibPath;
...
};

2、SEAL_PRESSURE.cpp中添加代码

cpp 复制代码
CSEAL_PRESSUREApp::CSEAL_PRESSUREApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
			TCHAR exeFullPath[MAX_PATH];
	GetModuleFileName(NULL,exeFullPath,MAX_PATH);
	m_Path = exeFullPath;
	for(int i = m_Path.GetLength() - 1; i > 0 ; i --)
	{
		if(m_Path.GetAt(i) == '\\')
			break;
	}
	SetCurrentDirectory(m_Path);
	m_Path = m_Path.Left(i);
	m_DataPath = m_Path + "\\DATA\\";
	m_TempPath = m_Path + "\\TEMP\\";
	m_LibPath = m_Path + "\\LIB\\";	
	CreateDirectory(m_LibPath,FALSE);
	CreateDirectory(m_DataPath,FALSE);
	CreateDirectory(m_TempPath,FALSE);
}

运行程序

相关推荐
Ljwuhe37 分钟前
类与对象(中)——运算符重载
开发语言·c++
郝学胜-神的一滴38 分钟前
深入理解链表:从基础到实践
开发语言·数据结构·c++·算法·链表·架构
crescent_悦1 小时前
C++:Have Fun with Numbers
开发语言·c++
mjhcsp1 小时前
C++轮廓线 DP:从原理到实战的深度解析
开发语言·c++·动态规划
ArturiaZ1 小时前
【day36】
数据结构·c++·算法
CodeJourney_J2 小时前
从“Hello World“ 开始 C++
c语言·c++·学习
tod1133 小时前
C++ 核心知识点全解析(八)
开发语言·c++·面试经验
Ljwuhe3 小时前
C++类与对象(上)
开发语言·c++
killer_queen48043 小时前
AI_agent(三) MCP协议(二)
c++·agent·mcp·a2a