Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get the file extension?

Status
Not open for further replies.

GON

Programmer
Jan 3, 2002
4
NO
Hi!
I'm a newbie to VBscript and need some help...

I know i can get the filetype by using file.type, but is there a similiar way to get just the file extension?
Anyone?

regards,
GON
 
Here is a easy way:

Code:
strtest = "afile.txt"

strextension = left(strtest,len(strtest) - 4)

msgbox strextension

Hope that works for you.

Roger
 
hi just another way fo you to use :O)

Dim MyString, MyArray, ext
MyString = "afile.txt"
MyArray = Split(MyString, ".")
' MyArray(0) contains "afile"
' MyArray(1) contains "txt"
ext = MyArray(1)
response.write ext

hope this is alrighty
cheers
storm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top