Forum Moderators: open

Message Too Old, No Replies

Searching files Locally

from webserver

         

RainMaker

2:17 pm on Jun 4, 2003 (gmt 0)

10+ Year Member



I was wondering if there was any way to be able to search files locally using ASP.NET. I can search files just fine when I am on the box that has the webpage on it. But if I want to access my page remotely, for some reason it doesn't search that machine locally. What I am doing is I am selecting files from a dialog box that has to be local to that machine. That part is fine but afterwards I have to search that very same directory for some things and for some reason the server wants to think that it is still it's local filesystem instead of its remote request, can anyone help?

mattglet

4:55 pm on Jun 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



are you trying to make a search function, that will search the contents of certain pages? or are you just looking for a directory browser?

-Matt

RainMaker

5:19 pm on Jun 4, 2003 (gmt 0)

10+ Year Member



I am trying to make a local directory browser. Right now I select a file local on my machine, but I am accessing the webpage remotely. Well when I search the directory from where I selected my file, the web page doens't search local, it searches local to it.

RainMaker

10:23 pm on Jun 6, 2003 (gmt 0)

10+ Year Member



noobody loves me! sob sob....

Xoc

10:52 pm on Jun 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You want to install the Indexing service on the local machine. Then use

In global.asa
[6]


Application("indexserver_ConnectionString") _
= "Provider=MSIDXS.1;Integrated Security .="""";Data Source=indexingservicename;"
[/6]

In form:

[6]


<form action="search.asp" method="get">
Search for:<br />
<input type="text" name="txtSearch" size="60" value="<%=Request("txtSearch")%>" /><br />
<input type="submit" value="Search" /><br />
Example: conventions and array<br />
<a href="searchlang.asp">Search Language</a><br />
</form>

<%
Sub SearchResults()
Dim rst
Dim strQuery
Dim fld
Dim nod
Dim strTitle
Dim strVPath
Dim strCharacterization
Dim strCreateDate
Dim strModifiedDate
Dim strSize
Dim astrSearchTerms
Dim iastrSearchTerms

If Not IsEmpty(Request("txtSearch")) Then
strQuery = Request("txtSearch")
astrSearchTerms = Split(strQuery)

strQuery = ""
For iastrSearchTerms = LBound(astrSearchTerms) To UBound(astrSearchTerms)
If iastrSearchTerms > LBound(astrSearchTerms) Then
strQuery = strQuery & " and " & astrSearchTerms(iastrSearchTerms)
Else
strQuery = astrSearchTerms(iastrSearchTerms)
End If
Next
Set rst = Server.CreateObject("ADODB.Recordset")
rst.Source = "SELECT Characterization, Create, DocTitle, Size, VPath, Write " _
& "FROM SCOPE() WHERE CONTAINS('" & strQuery & "') ORDER BY Rank Desc"
rst.ActiveConnection = Application("indexserver_ConnectionString")
On Error Resume Next
rst.Open
If Err.number = 0 Then
On Error Goto 0
If rst.EOF Then
Call Response.Write("No pages found for '" & Server.HTMLEncode(strQuery) & "'")
Else
Call Response.Write("<ol class=""smaller"">" & vbCrLf)
Do Until rst.EOF
Call Response.Write("<li>" & vbCrLf)
With rst.Fields
If IsNull(.Item("DocTitle").value) Then
Set nod = mdomSiteMap.SelectSingleNode("/descendant::topic[attribute::path='" _
& rst("vpath") & "']")
If Not (nod Is Nothing) Then
strTitle = nod.attributes.getNamedItem("title").value
Else
strTitle = "No Title"
End If
Else
strTitle = .Item("DocTitle").Value
End If
strVPath = .Item("VPath").Value
strCharacterization = .Item("Characterization").Value
strCreateDate = FormatDateTime(.Item("Create").Value, vbShortDate)
strModifiedDate = FormatDateTime(.Item("Write").Value, vbShortDate)
strSize = CStr(.Item("Size").Value)
Call Response.Write("<a href='" & strVPath & "'>" & strTitle & "</a><br />" & vbCrLf)
Call Response.Write(strCharacterization & "...<br />" & vbCrLf)
Call Response.Write("Created: " & strCreateDate & " Last Modified: " _
& strModifiedDate & " Size: " & strSize & "<br />" & vbCrLf)
Call Response.Write("URL: " & strVPath & "<br />" & vbCrLf)
Call Response.Write("</li>" & vbCrLf)
End With
rst.MoveNext
Loop
Call Response.Write("</ol>" & vbCrLf)
End If
rst.Close
Else
Call Response.Write(Err.Description)
End If
Set rst = Nothing
End If
End Sub

Call SearchResults()
%>

[/6]

Sorry, just noticed that you wanted ASP.NET. The above is ASP. But you get the idea. The basic scheme is that you can use SQL to query the indexing service.

RainMaker

8:49 pm on Jul 3, 2003 (gmt 0)

10+ Year Member



I know I am a little late but thanks very much for the code. I appreciate you taking the time.