//得到目录名称
CString GetPathName(CString strPathName)
{
int index = str.ReverseFind('\\');
CString strPath = _T("");
if(index >= 0)
{
strPath = strPathName.Left(index);
}
else
{
index = strPathName.ReverseFind('/');
strPath = strPathName.Left(index);
}
return strPath;
}
//得到文件名称不包含扩展名
CString GetFileName(CString strPathName)
{
CString strFileName = _T("");
int index = strPathName.ReverseFind('\\');
if(index > 0)
{
index ++;
strFileName = strPathName.Mid(index);
index = strFileName.ReverseFind('.');
strFileName = strFileName.Left(index);
return strFileName;
}
else
{
index = strPathName.ReverseFind('/');
index ++;
strFileName = strPathName.Mid(index);
index = strFileNa
MFC 如何从字符串中分离文件名与路径
于 2022-03-31 13:59:12 首次发布
本文介绍如何在MFC(Microsoft Foundation Classes)中使用C++代码从字符串路径中提取文件名和路径。通过示例代码展示利用_MFC_库的Path类功能,详细解析了分离过程。
摘要由CSDN通过智能技术生成