MFC relative path and create directory

MFC relative path and create directory

relative path

	TCHAR szPath[MAX_PATH];
	TCHAR szFile[] = TEXT("..\\员工人脸\\123");
	if (GetModuleFileName(NULL, szPath, MAX_PATH) > 0) {
    
      
		// GetModuleFileName 获取当前进程完整路径
		if (PathRemoveFileSpec(szPath)) {
    
    
			// PathRemoveFileSpc 将路径末尾的文件名和反斜杠去掉。
			PathAppend(szPath, szFile);  //将szFile附加在szPath后面
		}
	}

Create a directory

	if (CreateDirectory((LPCTSTR)szPath, NULL))//创建目录
		AfxMessageBox(_T("成功创建了目录"));
	else
		AfxMessageBox(_T("创建目录失败"));

Guess you like

Origin blog.csdn.net/CSDN_KO/article/details/115001782