Este es el código de un buscador de ficheros que tengo. El caso es que hace un poco lo que le da la gana. La búsqueda no es del todo precisa y el tiempo de espera es excesivamente ridículo.
Si alguno veis cual es el motivo os agradecería que me ayudaseis ya que me esta trayendo por el camino de la amargura.
<%if request("lanzar")="true" then%>
<%
Const fsoForReading = 1
Dim strbusca_palabra
strbusca_palabra = Request("busca_palabra")
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Dim objFolder
Set objFolder = objFSO.GetFolder(Server.MapPath("/data/documentacion/clientes/contratos/Contratos A/"))
response.write objFolder & "<BR>"
Dim SubFolders
Set SubFolders = objFolder.SubFolders
Dim objFile, objTextStream, strFileContents, bolFileFound
bolFileFound = False
i = 0
For Each objFolder1 in SubFolders
i = i + 1
if i <> 1 then
Set objFolder = objFSO.GetFolder(Server.MapPath("/data/documentacion/clientes/contratos/Contratos A/" & objFolder1.name))
end if
For Each objFile in objFolder.Files
If Response.IsClientConnected then
Set objTextStream = objFSO.OpenTextFile(objFile.Path,fsoForReading)
strFileContents = objTextStream.ReadAll
on error resume next
If InStr(1,strFileContents,strbusca_palabra,1) then
if i <> 1 then
Response.Write "<LI><A HREF=" & objFolder1.name & "/" & objFile.Name & ">" & objFile.Name & "</A><BR>"
else
Response.Write "<LI><A HREF=" & objFile.Name & ">" & objFile.Name & "</A><BR>"
end if
bolFileFound = True
End If
objTextStream.Close
End If
Next
Next
if Not bolFileFound then Response.Write "No se encontraron resultados<br><a href='javascript:;history.back(-1)'>Intentar nuevamente</a>"
Set objTextStream = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
Set SubFolders = Nothing
%>
<%else%>
Formulario
<table width="100%" border="0">
<tr>
<td><form name="form1" method="post" action="">
<input name="lanzar" type="hidden" id="lanzar" value="true">
<input name="busca_palabra" type="text" id="busca_palabra">
<input type="submit" name="Submit" value="Buscar">
</form></td>
</tr>
</table>
<%end if%>
Un saludito a todos.