<%@LANGUAGE=VBSCRIPT CODEPAGE=936%>
<%
dim st
st=timer()
'******************************************************************
'***************Search hard disk file class SearchFile ************
'************ Call method: ************
'************Set newssearch=new SearchFile 'Declaration************
'************newsearch.Folder=F:+E:'Incoming search source*************
'************newsearch.keyword=assembly' keyword***************
'************newsearch.Search 'Start search************
'************Set newssearch=Nothing 'end*************
'************Copyright(c)完望完月完月****************
'*************** http://btyz.51web.cn/ ************
'******************************************************************
Class SearchFile
dim Folders 'Passing an absolute path, multipath uses + sign to connect, no spaces
dim keyword 'Passing keywords
dim objFso 'Define global variables
dim Counter 'Define global variables, the number of search results
'*****************initialization**************************************
Private Sub Class_Initialize
Set objFso=Server.CreateObject(Scripting.FileSystemObject)
Counter=0 'Initialize the counter
End Sub
'*********************************************************************
Private Sub Class_Terminate
Set objFso=Nothing
End Sub
'****************** Public member, method called *******************************
Function Search
Folders=split(Folders,+) 'Convert to array
keyword=trim(keyword) 'Remove the spaces before and after
if keyword= then
Response.Write(<font color='red'> keyword cannot be empty</font><br/>)
exit Function
end if
'Just determine whether 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,&)
if flag then 'The keyword cannot contain //:|&
Response.Write(<font color='red'> keyword cannot contain //:|&</font><br/>)
Exit Function 'If this is included, exit
end if
'Multi-path search
dim i
for i=0 to ubund(Folders)
Call GetAllFile(Folders(i)) 'Call loop recursive function
next
Response.Write (Total <font color='red'>&Counter&</font> results were searched)
End Function
'******************************************
Private Function GetAllFile(Folder)
dim objFd,objFs,objFf
Set objFd=objFso.GetFolder(Folder)
Set objFs=objFd.SubFolders
Set objFf=objFd.Files
'Travel through subfolders
dim strFdName 'Declare the subfolder name
'************Visit subfolders*******
on error resume next
For Each OneDir In objFs
strFdName=OneDir.Name
'The system folder is not included in the traversal
If strFdName<>Config.Msi EQV strFdName<>RECYCLED EQV strFdName<>RECYCLER EQV strFdName<>System Volume Information Then