注册 登录
编程论坛 VB.NET论坛

在一个字符串路径中获取文件名称?vb2008

twzy 发布于 2010-04-06 14:56, 1601 次点击
如“E:\xxxx\xxxxx\abc.txt”这是一个字符串,我只取“abc”这个字符串,但是路径不确定,还望高手指点一二。谢谢了
5 回复
#2
czyzhuo2010-04-07 09:51
查找\和.之间的字符串就可以了
#3
wuyazhe2010-04-09 13:39
MsgBox(Path.GetFileName("E:\xxxx\xxxxx\abc.txt"))
#4
sywzs2010-04-13 11:00
Dim STR1 As String = "E:\xxxx\xxxxx\abc.txt"
MsgBox(Mid(STR1, InStrRev(STR1, "\") + 1, InStr(STR1, ".") - InStrRev(STR1, "\") - 1))
#5
jelly_hao2010-05-12 13:31
Dim STR1 As String = "E:\xxxx\xxxxx\abc.txt"
MsgBox(Mid(STR1, InStrRev(STR1, "\") + 1, InStr(STR1, ".") - InStrRev(STR1, "\") - 1))
#6
jelly_hao2010-05-12 13:48
MsgBox(Path.GetFileName("E:\xxxx\xxxxx\abc.txt"))
这样得到的是abc.txt
1