您的位置:首页 > 其它

如何从完整的文件路径中分离文件名和路径名?

2010-10-05 12:05 387 查看
CString GetFileName(CString pathname)
{
for( int i=pathname.GetLength()-1; i>=0; i-- )
{
if( pathname[i]=='//' )
break;
}
return pathname.Mid( i+1 );
}

从路径中分离路径名(去除文件名):

CString GetPath(CString pathname)
{
int i = 0, j;
while( i<pathname.GetLength() )
{
if( pathname[i]=='//' )
j = i;
i++;
}
return pathname.Left( j+1 );
}

转自:

/article/5955824.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: