'****************************************************************************************************
'函数: GetFileNameFromPath
'作用: 从完整路径获取 所在目录
'输入: 完整路径, 目录分隔符
'返回: 所在目录
Public Function GetFileNameFromPath(ByVal strFullPath As String, Optional ByVal strSplitor As String = "\") As String
GetFileNameFromPath = Right$(strFullPath, Len(strFullPath) - InStrRev(strFullPath, strSplitor, , vbTextCompare))
End Function
上面这个是自己写的函数, 你把它拷到程序代码窗口的空白位置中或放在标准模块里, 然后用
Msgbox GetFileNameFromPath("E:\Mp3\卫兰 - 等.mp3")
就可以看到结果了.
函数的用法: GetFileNameFromPath(路径,分隔符)
分隔符默认是"\", 如果改为"/"则可以提取网页地址中的文件名如提取
http://www.sina.com.cn/index.htm 中的 index.htm 就是 Msgbox GetFileNameFromPath("
http://www.sina.com.cn/index.htm","/")