Connecting Tech Pros Worldwide Forums | Help | Site Map

search for specific filename from folder

Familiar Sight
 
Join Date: Jul 2007
Location: United Kingdom
Posts: 203
#1: May 12 '09
Hi

i've got folder with lots of images on it,
what i would like to do is trying to seach the specific image filename
using ( FileSystemObject ) & textbox

i've got this code that can search the files in folder bringing full list of file.

Expand|Select|Wrap|Line Numbers
  1.     set FileSysObj=CreateObject("Scripting.FileSystemObject")
  2.     strFileAndPath = request.servervariables("SCRIPT_NAME")
  3.     strPathOnly = Mid(strFileAndPath,1 ,InStrRev(strFileAndPath, "/"))
  4.     strFullPath = server.mappath(strPathOnly)
  5.     set fldr=FileSysObj.GetFolder(strFullPath)
  6.  
  7.     set FileList = fldr.Files
  8.     For Each FileIndex in FileList
  9.         'This bit excludes this page (and other asp files) from the list of links
  10.         if Lcase(right(FileIndex.Name, 4)) <> ".ini" then
  11.             Response.Write("<A HREF='" & FileIndex.name & "'>" & FileIndex.name & "</A><BR>")
  12.         end if
  13.     Next
  14.  
IS ANY BODY KNW HOW TO GET CRACK ON TO ACHIVE THIS RESULT ?

Familiar Sight
 
Join Date: Jul 2007
Location: United Kingdom
Posts: 203
#2: May 13 '09

re: search for specific filename from folder


any body kw\sssssssssssssssssssssssssssssssssssss
Thxs in advance
GazMathias's Avatar
Expert
 
Join Date: Oct 2008
Location: Bristol, United Kingdom
Posts: 145
#3: May 14 '09

re: search for specific filename from folder


This bit:

Expand|Select|Wrap|Line Numbers
  1.  Response.Write("<A HREF='" & FileIndex.name & "'>" & FileIndex.name & "</A><BR>")
  2.  
Becomes:

Expand|Select|Wrap|Line Numbers
  1. If instr(FileIndex.name,"[YOUR TEXT HERE]") >0 Then
  2. Response.Write("<A HREF='" & FileIndex.name & "'>" & FileIndex.name & "</A><BR>")
  3. End if
Obviously you need to feed the [YOUR TEXT HERE] bit with something.

Gaz
Reply