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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extract filenames and open file 2

Status
Not open for further replies.

optjco

IS-IT--Management
Apr 13, 2004
185
GB
I wonder if someone can help me I have the code shown below which extracts the file names from a certain folder all the file names refer to PDF's. What I am trying to do is to list the file names and then then click on any one of them to open it.

Any help would be appreciated

Code:
<%
  'Create FSO Object
  Dim objFSO
  Set objFSO = CreateObject("Scripting.FileSystemObject")


  Dim objFolder
  Set objFolder = objFSO.GetFolder("D:\kiwi-cag\production\CAG")

  Dim Files
  For Each File in objFolder.Files
    Response.Write(File.Name & "<br />")
  Next
%> 
[/code

Regards

Olly
 
Robert,
Tried your suggestions using inStr however It does not filter the list but just shows all the files in the folder. Thanks for your help anyway, some search facility is better than nothing which i is what i had before.

If you can think of anything else I can try I would appreciate it, in the mean time I will continue to plug away and see what I can find

Regards

Olly
 
Robert,
I have also tried adding a complete filename into the search value i.e.

PUR_P2512.PDF

The search then starts from that file name and continues to the end of the list

also this may seem like an elementary question but when you say "per chance is the page cached?" what exactly do you mean ?


Regards

Olly
 
could you post the modified/current code you're using at the moment? might help in figuring out what's going on.

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
 
Robert code as requested the first is the search page code I have copied both this and the rsults page so that I did not mess with the code that you helped me to get to work before

"Search Page code"
Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#99CCFF">
<form action="FolderListCAG1.asp" method="post" name="frmPrint" id="frmPrint">
  <div align="center">
    <input name="txtPrint" type="text" id="txtPrint" size="15" maxlength="15">
    <input type="submit" name="Submit" value="Artwork">
  </div>
</form>
<p align="center">&nbsp;</p>
</body>
</html>

"Results Page code"
Code:
<body bgcolor="#99CCFF">
<%
SearchValue  = Request("txtPrint")
MatchesFound = False ' pessimistic boolean for match finds
  'Create our FSO Object
  Dim objFSO
  Set objFSO = CreateObject("Scripting.FileSystemObject")

  'Stuff our folder into an object we can manipulate
  Dim objFolder
  Set objFolder = objFSO.GetFolder("D:\kiwi-cag\production\CAG")

  Dim Files
  For Each File in objFolder.Files
     If StrComp(File.Name,SearchValue,vbtextcompare) >= 0 Then
       Response.Write("<a href=""\\uktmwsa001\kiwi-cag\production\CAG\" &  File.Name & """>" & File.Name & "</a>" & "<br />")
       MatchesFound = True ' something was matched.
     End If
  Next
If Not MatchesFound Then
Response.Write "No Matches Found"
End If
%>


Regards

Olly
 
i copied and pasted the code, and it works fine, you may have cached results

refresh the search form before submitting it

then the results, refresh and select retry after you get them

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
 
Robert,
tried what you suggested still no luck !!

Regards

Olly
 
i dont know what to tell you the code is functional, from your post.

only things i changed is the path statement (i dont have a G drive)

try adding response.expires=0 in the first line of the results page, it's probably cached results.

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
 
Robert,
can I ask you a question?, how did you test my code

Regards

Olly
 
Robert,
got it working, i was looking through the whole of this thread and noticed that HowardMarks had suggested trying
Code:
If Left(File.Name,3) = "ABC" Then
   Response.Write("<a href=""\\uktmwsa001\kiwi-cag\production\CAG\" &  File.Name & """>" & File.Name & "</a>" & "<br />")
End If
so this is what I have now in the code

Code:
<body bgcolor="#99CCFF">
<%
SearchValue  = Request("txtPrint")
MatchesFound = False ' pessimistic boolean for match finds
  'Create our FSO Object
  Dim objFSO
  Set objFSO = CreateObject("Scripting.FileSystemObject")

  'Stuff our folder into an object we can manipulate
  Dim objFolder
  Set objFolder = objFSO.GetFolder("D:\kiwi-cag\production\CAG")

  Dim Files
  For Each File in objFolder.Files
     If Left(File.Name,3) = SearchValue Then
       Response.Write("<a href=""\\uktmwsa001\kiwi-cag\production\CAG\" &  File.Name & """>" & File.Name & "</a>" & "<br />")
       MatchesFound = True ' something was matched.
     End If
  Next
If Not MatchesFound Then
Response.Write "No Matches Found"
End If
%>

and it works every time, I cannot thank you enough for all the time and effort you have put in to help me with this. I wish i could give you a couple of more stars

[2thumbsup]:)[2thumbsup]


Regards

Olly
 
dont forget your URL slashes need to be the OTHER way

"//uktmwsa001/kiwi-cag/production/CAG/"

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top