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");
//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");
相关文章推荐
- php获取url字符串截取路径的文件名和扩展名的函数
- AB程序核心代码(MFC从文件读取一行+MFC字符串处理+C在文件末尾追加内容)
- 编写一个Python程序,能在当前目录以及当前目录的所有子目录下查找文件名包含指定字符串的文件,并打印出相对路径
- 文件路径类 字符串的各种截取方式,包括截取到文件名
- 编写一个程序,能在当前目录以及当前目录的所有子目录下查找文件名包含指定字符串的文件,并打印出相对路径。
- Source Insight查看ARM汇编源 && 打开project窗口出错 && 高亮显示程序 && 标题栏显示全路径 && 从工程批量去除文件 && 添加无扩展名文件 && 快捷键插入时间日期
- 关于java下载文件及获取文件路径和截取字符串的一点记录
- MFC 文件打开对话框(CFileDialog类或OPENFILENAME结构体)后,保持程序的路径不变
- 程序关联文件 获取双击文件路径 MFC/VC
- VC/MFC 设置程序与文件关联与双击文件获取文件路径
- 监测程序详细介绍,快捷键的设置;txt文件里面一行行的读取、删除、添加字符串等;根据程序路径名以及程序名判断程序是否在运行;
- lua中如何截取字符串(比如截取文件路径字符串中的文件名)
- MFC程序中将软件打包后,setup.exe文件自己电脑运行正常,别人电脑显示找不到文件路径
- lua 文件路径 字符串处理 数据结构 正则表达式 Class 程序集
- php获取url字符串截取路径的文件名和扩展名的函数
- C#调用MFC程序DLL库——MFC项目DLL生成问题、DLL引用链问题、DLL读取配置文件路径问题
- java获取文件扩展名的方法小结【正则与字符串截取】
- MFC程序中创建文件夹(文件路径)
- VC/MFC 设置程序与文件关联与双击文件获取文件路径
- C#控制台基础 path.changeextension一个路径字符串中的文件扩展名