1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| Const fsoLecture = 1
Dim strChaine, strResult, strMess
strChaineRech = Request("ChaineRech")
strResult = "<li>Veuillez entrer une chaîne de caractères d'au moins 3 caractères...</li>"
if len(strChaineRech) > 2 then
strResult = "Résultat:<br>"
' Récupérer chaque fichier
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Dim objRep, nPath
Set objRep = objFSO.GetFolder(Server.MapPath("documents"))
Dim objFichier, objTexteStream, strFichier
For Each objFichier in objRep.Files
If Response.IsClientConnected then
Set objTexteStream = objFSO.OpenTextFile(objFichier.Path,fsoLecture)
strFichier = objTexteStream.ReadAll
If InStr(1,strFichier, strChaineRech,1) then
strResult = strResult+ "<li><a href=""../labo/documents/" & objFichier.Name & """>" & objFichier.Name & "</a></li>"
End If
objTexteStream.Close
End If
Next
Set objTexteStream = Nothing
Set objRep = Nothing
Set objFSO = Nothing
End if
<form method="post" action="base.asp" id=form1 name=form1>
<input type="text" name="ChaineRech">
<input type="submit" name="Submit" value="Recherche">
</form> |
Partager