京东11.11大促主会场领京享红包更优惠

 找回密码
 立即注册

QQ登录

只需一步,快速开始

VC 中如何从字符串中分离文件名与路径(CString)

2022-9-4 21:51| 发布者: zhaojun917| 查看: 6086| 评论: 0

摘要: 获取文件路径:CString strPath;int n=m_strOriFileName.ReverseFind('\\')+1;strPath=m_strOriFileName.Left(n);获取文件名:CString strFile;int n=m_strUntFileName.GetLength()-m_strOriFileName.ReverseFind('\ ...
 获取文件路径:
CString strPath;
int n=m_strOriFileName.ReverseFind('\\')+1;
strPath=m_strOriFileName.Left(n);

获取文件名:
CString strFile;
int n=m_strUntFileName.GetLength()-m_strOriFileName.ReverseFind('\\')-1;
strFile=m_strOriFileName.Right(n);

同理,获取文件后缀名则为:
CString strFileType;
int n=m_strUntFileName.GetLength()-m_strOriFileName.ReverseFind('.')-1;
strFileType=m_strOriFileName.Right(n);
关闭

站长推荐上一条 /6 下一条

QQ|手机版|小黑屋|梦想之都-俊月星空 ( 粤ICP备18056059号 )

GMT+8, 2025-2-24 05:55 , Processed in 0.027049 second(s), 17 queries .

Powered by Mxzdjyxk! X3.5

© 2001-2025 Discuz! Team.

返回顶部