VB获取目录的问题

来源:百度知道 编辑:UC知道 时间:2024/05/09 09:08:30
有个全路径
x:\abc\123.txt
怎么把123.txt去掉
我只要路径……

sFullName = "x:\abc\123.txt "
sPath = Left(sFullName, InStrRev(sFullName, "\"))
sPath即是路径

笨方法

a=split(全路径,"\")
for i=0 to UBound(a)-1
目录=目录 & a(i) & "\"
next
print 目录

a = InStrRev("x:\abc\123.txt", "\")
Path = Left$("x:\abc\123.txt", a)

str1="x:\abc\123.txt"
k = InStr(str1, "123.txt")
h = Len(str1)
str1 = Left("x:\abc\123.txt", h - k)
Print str1