c++

截取文件名和文件后缀

c++

Posted by YiMiTuMi on June 13, 2022

截取文件名

CString strFilePath = L"‪C:\\Users\\WGH\\Desktop\\移植.txt";

int iVal = strFilePath.ReverseFind('\\');
CString strFileName;
if (iVal != -1)
{
	strFileName = strFilePath.Mid(iVal + 1, strFilePath.GetLength());
}

截取文件后缀

CString strFileName = L"‪移植.txt";

int iVal = strFileName.ReverseFind('.');
CString strSuffix;
if (iVal != -1)
{
	strSuffix = strFileName.Mid(iVal, strFileName.GetLength());
}

蓝色妖姬 – 相守