Reply
Search in folders
Old 11-24-2006, 07:50 AM Search in folders
Junior Talker

Posts: 3
Name: Hans
Hi,
Could use some help with this, as I'm a total newbie in asp.
I'm building an Intranet site and found a search script.
This is the html code:
HTML Code:
<HTML>
<BODY>
<FORM METHOD=POST ACTION="TextSearch.asp">
  Enter text to search for:
  <INPUT TYPE=TEXT NAME=SearchText>
  <INPUT TYPE=SUBMIT VALUE="Zoek!">
</FORM>
</BODY>
</HTML>
Followed by this TextSearch.asp script:
Code:
<HTML><BODY>
<B>Search Results for <%=Request("SearchText")%></B><BR>
<%
Function SearchFolder(oFSO, oFolder, sSearch)
 Dim bFound, oTS
 bFound = False
 For Each oFile in oFolder.Files
 If oFile.Size > 0 Then
  If Response.IsClientConnected Then
   Set oTS = oFSO.OpenTextFile(oFile.Path,fsoForReading)
 
   strFileContents = oTS.ReadAll
 
   If InStr(1,strFileContents,sSearch,1) then
    Response.Write "<LI><A HREF=""/" & oFile.Name & _
                      """>" & oFile.Name & "</A><BR>"
 
    bFound = True
   End If
 
   oTS.Close
  End If
 End If
Next
' For Each oFile in oFolder.Files
'   If Response.IsClientConnected then
'     Set oTS = oFSO.OpenTextFile(oFile.Path,fsoForReading)
' 
'     strFileContents = oTS.ReadAll
' 
'     If InStr(1,strFileContents,sSearch,1) then
'        Response.Write "<LI><A HREF=""/" & oFile.Name & _
'                       """>" & oFile.Name & "</A><BR>"
' 
'        bFound = True
'     End If
' 
'     oTS.Close
'   End If
' Next
 For Each oSubFolder In oFolder.Subfolders
  bFound = bFound Or SearchFolder(oFSO, oSubFolder, sSearch)
 Next
 SearchFolder = bFound
End Function
Const fsoForReading = 1
Dim strSearchText
strSearchText = Request("SearchText")
'Now, we want to search all of the files
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
 
Dim objFolder
Set objFolder = objFSO.GetFolder(Server.MapPath("/"))
Dim objFile, objTextStream, strFileContents, bolFileFound
bolFileFound = SearchFolder(objFSO, objFolder, strSearchText)
 
if Not bolFileFound then Response.Write "Helaas.. niets gevonden"
Set objTextStream = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
%>
</BODY></HTML>
Problem is that the search is performed in the wwwroot directory, but I want it to search on the network.
More specific, I have another script to display directories and can browse into those dirs.

The goal is to show this searchfield and button in left (menu) frame when mainframe is filled with directory listing.
(Other option is to show searchfield in mainframe)
Then when a search is requested, the searchscript should search in the directory displayed in mainframe.

I have no clue however how to do this.. so please, have a look at this.. and get my eternal thanks..
pookie62 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 11-24-2006, 12:45 PM Re: Search in folders
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Change this line:
Code:
Set objFolder = objFSO.GetFolder("C:\")
That would search your entire C:\ drive. Modify as appropriate for network paths/mapped drives (although I haven't tried it for either of those.)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 11-24-2006, 01:04 PM Re: Search in folders
Junior Talker

Posts: 3
Name: Hans
Thanks for your reply, going to try this monday and let know the results!
pookie62 is offline
Reply With Quote
View Public Profile
 
Old 11-24-2006, 09:33 PM Re: Search in folders
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Cool deal.

Good luck!
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 11-28-2006, 02:30 AM Re: Search in folders
Junior Talker

Posts: 3
Name: Hans
Hmm, getting permission denied error.
After some testing the only location I get results is in the wwwroot folder.
Weird, cause I have another script browsing across networkfolders which is going fine..have an issue with that one as well.. I get the contents of a directory listed, but when I click a Word doc, the script treats it like a dir, instead of opening the doc..
Pfoeee....
Anyone done something similar ?
pookie62 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Search in folders
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12579 seconds with 13 queries