469,623 Members | 1,800 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,623 developers. It's quick & easy.

Making links with the FileSystemObject...

Greetings!

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>"
Next

'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 1074
dorinbogdan
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
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.