<%
Dim strPath ' Path of directory to search
Dim objFSO ' FileSystemObject variable
Dim objFolder ' Folder variable
Dim objItem ' Variable used to loop through the
'contents of the folder
Dim strQuery ' Search string
' You could just as easily read this from some sort of input,
' but I don't need you guys roaming around our server so
' I've hard coded it to a directory I set up to illustrate
' the sample.
' NOTE: As currently implemented, this needs to end with the /
strPath = "cust/1lancomo/"
' Retrieve the search string. If empty it will return all files.
strQuery = Request.QueryString("query")
' Show our search form and a few links to some sample searches
%>
<%
' Create our FSO and get a handle on our folder
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(Server.MapPath(strPath))
' Show a little description line and the title row of our table
%>
|
File Name:
|
|
<%
If (objFSO.FileExists(Server.MapPath(strPath + "slas%20courses.pdf")))=true Then
Response.Write("File exists.")
Else
Response.Write("File does not exist.")
End If
%>
|
<%
For Each objItem In objFolder.Files
If InStr(1, objItem.Name, strQuery, vbTextCompare) <> 0 Then
%>
|
<%= Server.MapPath(strPath) %>
|
<%
End If
Next 'objItem
' All done! Kill off our object variables.
Set objItem = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
%>
|
|
|