Hard drive <% @LANGUAGE = "VBSCRIPT" codepage= "936"%>
<%
Dim St
St=timer ()
'*************************************************************
' ************* search hard disk files for class Searchfile *************
' ************* Call Method: *************
' *************set newsearch=new searchfile ' statement *************
' *************newsearch. Folder= "F:+e:" ' Incoming search source *************
' *************newsearch.keyword= ' assembly ' keyword *************
' *************newsearch. Search ' Start searching *************
' *************set newsearch=nothing ' end *************
' *************copyright (c) Drunk rain Indus Station *************
' *************http://btyz.51web.cn/*************
'*************************************************************
Class Searchfile
Dim Folders ' Pass in absolute path, multiple paths using + number connection, no spaces
Dim keyword ' incoming keyword
Dim objFSO ' Defines global variables
Dim Counter ' Defines global variables, number of search results
' ***************** initialization **************************************
Private Sub Class_Initialize
Set objfso=server.createobject ("Scripting.FileSystemObject")
Counter=0 ' Initialization counter
End Sub
'************************************************************
Private Sub Class_Terminate
Set objfso=nothing
End Sub
' ************** public members, calling methods ***************************
Function Search
Folders=split (Folders, "+") ' converts to arrays
Keyword=trim (keyword) ' Remove space before and after
If keyword= "" Then
Response.Write ("<font color= ' red ' > keyword cannot be empty </font><br/>")
Exit Function
End If
' Determine if illegal characters are included
FLAG=INSTR (keyword, "\") or InStr (keyword, "/")
Flag=flag or InStr (keyword, ":")
Flag=flag or InStr (keyword, "|")
Flag=flag or InStr (keyword, "&")
The IF flag then ' keyword cannot contain \/:|&
Response.Write ("<font color= ' red ' > keyword cannot contain/\:|&</font><br/>")
Exit Function ' Exits if included with this
End If
' Multi-Path search
Dim i
For i=0 to UBound (Folders)
Call Getallfile (Folders (i)) ' calls a circular recursive function
Next
Response.Write ("Search to <font color= ' red ' >" &Counter& "</font> results")
End Function
' *************** Calendar files and folders ******************************
Private Function getallfile (Folder)
Dim objfd,objfs,objff
Set Objfd=objfso.getfolder (Folder)
Set objfs=objfd.subfolders
Set Objff=objfd.files
' Calendar subfolders
Dim strfdname ' Declares subfolder name
' ********* Calendar subfolders
On Error Resume Next
For each onedir in OBJFS
Strfdname=onedir.name
' System folders are not listed in the calendar
If strfdname<> "Config.msi" EQV strfdname<> "recycled" EQV strfdname<> "RECYCLER" EQV > "System Volume Information" Then
sfn=folder& "\" &strfdname ' absolute path
Call Getallfile (SFN) ' calls recursion
End If
Next
Dim strflname
' ********** Calendar file ********
For each onefile in OBJFF
Strflname=onefile.name
' Desktop.ini and folder.htt out of range
If strflname<> "Desktop.ini" EQV strflname<> "Folder.htt" Then
fn=folder& "\" &strflname
Counter=counter+coloron (FN)
End If
Next
'***************************
' Close each object instance
Set objfd=nothing
Set objfs=nothing
Set objff=nothing
End Function
' ********************* generation matching pattern ***********************************
Private Function createpattern (keyword)
Createpattern=keyword
Createpattern=replace (Createpattern, ".", "\.")
Createpattern=replace (Createpattern, "+", "\+")
Createpattern=replace (Createpattern, "(", "\)
Createpattern=replace (Createpattern, ")", "\)")
Createpattern=replace (Createpattern, "[", "\[")
Createpattern=replace (Createpattern, "]", "\]")
Createpattern=replace (Createpattern, "{", "\{")
Createpattern=replace (Createpattern, "}", "\}")
Createpattern=replace (Createpattern, "*", "[^\\\/]*") ' * # match
Createpattern=replace (Createpattern, "?", "[^\\\/]{1}") ' # match
Createpattern= "(" &CreatePattern& ") +" ' overall match
End Function
' ************************** search and color the keywords *************************