然后我们可以对这个字符串使用split方法,这个方法会返回一个数组,取数组的最后一个元素就是后缀了,如
string myfile="d:\\myfile.mdb"
string subname=myfile.split('.')[1]//后缀获得
asp获取文件名和扩展名的函数代码<%Function getFilename(text)
text = Left(text,inStrRev(fl,".")-1)
getFilename = textEnd FunctionFunction getExtn(text)
text = Left(text,inStr(text,".")-1)
getExtn = text
End Function
%>
这样就可以了,获得就是 .扩展名
<%
lname="文本字段名字"
la=split(lname,"/")
num=ubound(la)
lb=split(la(num),".")
num2=ubound(lb)
response.Write("."&lb(num2))
%>
这样获得的是整个文件名
<%
a="c:/windows/windows/windows/tex.txt"
b=split(a,"/")
a=ubound(b)
response.Write(b(a))
%>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)