472,094 Members | 2,494 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,094 software developers and data experts.

Making links with the FileSystemObject...


I am using the following code to generate links to files on a website.

Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

'Get the folder object associated with the directory
Dim objFolder
Set objFolder = objFSO.GetFolder("C:\filepath\")

Response.Write "The files found in " & objFolder.Name & ":<br>"

'Loop through the Files collection
Dim objFile
For Each objFile in objFolder.Files
Response.Write "<a href='" & objFolder.Name & "/" & objFile.Name & "'>" & objFile.Name & "</a> <br>"

'Clean up!
Set objFolder = Nothing
Set objFile = Nothing
Set objFSO = Nothing

My question is how do I remove the file extension so that when the link outputs, the file extension is not there.

I have been trying iterations of getBaseName and cannot figure it out.

Any help would be great.
Mar 13 '07 #1
1 1101
839 Expert 512MB
In the For Each loop use:
Expand|Select|Wrap|Line Numbers
  1. Response.Write "<a href='" & objFolder.Name & "/" & objFile.Name & "'>" & Left(objFile.Name, InStrRev(objFile.Name, ".") - 1) & "</a> <br>"
Mar 14 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by John Dewbert | last post: by
2 posts views Thread by Sean S - Perth, WA | last post: by
2 posts views Thread by Luis Esteban Valencia | last post: by
1 post views Thread by G Gerard | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.