您的位置:首页 > 其它

mfc字符串截取-程序路径,文件扩展名等

2010-03-26 13:36 281 查看
//在全路径获取文件名
//const CString & localFileName
wchar_t tempStr[100]; //storage the file name
memset(tempStr,0,100);
int strLen = localFileName.GetLength();
int i = strLen - 1;
int fileLen = 0;
while (localFileName[i] != '//')
{
i--;
}
while(i++ < strLen)
{
tempStr[fileLen++] = localFileName[i];
}

//获取文件扩展名
int i = fileName.GetLength() - 1;
wchar_t fileType[10];
memset(&fileType,0,10);
while(fileName[i] != '.' && i != 0)
{
 i--;
}
if (i == 0)
{
 return NULL;
}
else
{
int j = i + 1;
int k = 0;
while(j < fileName.GetLength())
{
 fileType[k++] = fileName[j++];
}
 CString type = fileType;
}

//更改文件后缀名
 wchar_t strResult[200];
 memset(strResult,0,200);
 int StrLen = zipPath.GetLength();
 for(int i = StrLen; i > 0; i--)
 {
  if (zipPath[i] == '.')
  {
   wcsncpy_s(strResult, zipPath,i);
   break;
  }
 }
 CString iniPath = strResult;
 iniPath.Append(L".ini");
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mfc 扩展 null file
相关文章推荐