|
-
Nov 13th, 2000, 06:57 AM
#1
Thread Starter
Hyperactive Member
How can I get a list of say .PDF files in a given directory using ASP.
Thanks in advance for any help provided.
VB 6 Enterprise Edition SP4
ADO, SQL 7/2000, ASP and some JavaScript

>> Life goes on, but for how long? <<
If you can smile when things go wrong, you have someone in mind to blame
-
Nov 13th, 2000, 10:54 AM
#2
You could do it with the File System Object. This code would make a list of all the .pdf docs in the same directory as the ASP. Change 'strPath' to change the folder that's examined. If you didn't want to simply display the files you could put them into a dynamic array or something.
Code:
<%
Dim objFSO
Dim objFolder
Dim objFile
Dim strPath
Dim strHTML
strPath = Request.ServerVariables("APPL_PHYSICAL_PATH")
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strpath)
For Each objFile In objFolder.Files
If InStr(1, objFile.Name, ".pdf") > 0 Then
strHTML = strHTML & objFile.Name & "<BR>" & vbcrlf
End If
Next
Response.Write strHTML
Set objFile = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
%>
Paul
-
Nov 13th, 2000, 11:18 AM
#3
Thread Starter
Hyperactive Member
This worked great thanks.
Do you know if its possible to display the Title of the PDF document instead of the file name?
Thanks in advance for any help provided.
VB 6 Enterprise Edition SP4
ADO, SQL 7/2000, ASP and some JavaScript

>> Life goes on, but for how long? <<
If you can smile when things go wrong, you have someone in mind to blame
-
Nov 13th, 2000, 11:27 AM
#4
You're welcome. FSO is pretty slick but I don't think you could get at the title of the PDF without having some way to open up and examine the PDF itself (you'd need some kind of Adobe Acrobat object that may or may not exist). One thing you could do is (hope your PDFs are nicely named and) remove the .PDF extension to display the filename without extension like so:
strHTML = strHTML & Mid$(objFile.Name, 1, Len(objFile.Name) - 4) & "<BR>" & vbcrlf
rather than the...
strHTML = strHTML & objFile.Name & "<BR>" & vbcrlf
...used in my previous example...which may or may not work for you.
Cheers,
Paul
-
Nov 13th, 2000, 11:34 AM
#5
Thread Starter
Hyperactive Member
Thanks. I'll have to see if its possible to have the names changed, thats not my department.
I know I can get Cold Fusion to display the title, but I don't want to use it (I don't like it)
Thanks in advance for any help provided.
VB 6 Enterprise Edition SP4
ADO, SQL 7/2000, ASP and some JavaScript

>> Life goes on, but for how long? <<
If you can smile when things go wrong, you have someone in mind to blame
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|