A hard disk File search ASP source code

Source: Internet
Author: User
The hard drive may have some harm, please do not use illegal attempt, otherwise the consequence is conceited
<%
' ************************** code originated from the network ***********************
' ****************** may have certain harmfulness, please do not use illegal attempt, otherwise the consequence is arrogant *******************
' ********************** modification: blue2004***********************
' *************setnewsearch=newsearchfile ' statement *************
' *************newsearch. Folder= "F:+e:" ' Incoming search source *************
' *************newsearch.keyword= ' assembly ' keyword *************
' *************newsearch. Search ' Start searching *************
' *************setnewsearch=nothing ' End *************
'*************************************************************
Timeout setting for server.scripttimeout=99999 ' program loading
Classsearchfile
Dimfolders ' incoming absolute path, multiple paths using + number connection, no spaces
Dimkeyword ' incoming keyword
DIMOBJFSO ' defines global variables
Dimcounter ' defines global variables, number of search results
' ***************** initialization **************************************
Privatesubclass_initialize
Setobjfso=server.createobject ("Scripting.FileSystemObject")
Counter=0 ' Initialization counter
Endsub
'************************************************************
Privatesubclass_terminate
Setobjfso=nothing
Endsub
' ************** public members, calling methods ***************************
Functionsearch
Folders=split (Folders, "+") ' converts to arrays
Keyword=trim (keyword) ' Remove space before and after
Ifkeyword= "" Then
Response.Write ("<fontcolor= ' red ' > keyword cannot be null </font><br/>")
Exitfunction
endif
' Determine if illegal characters are included
FLAG=INSTR (keyword, "") orinstr (keyword, "/")
FLAG=FLAGORINSTR (keyword, ":")
FLAG=FLAGORINSTR (keyword, "|")
FLAG=FLAGORINSTR (keyword, "&")

The Ifflagthen ' keyword cannot contain/:|&
Response.Write ("<fontcolor= ' red ' > keyword cannot contain/:|&</font><br/>")
Exitfunction ' If you include this, quit
endif
' Multi-Path search
Dimi
Fori=0toubound (Folders)
Callgetallfile (Folders (i)) ' calls circular recursive functions
Next
Response.Write ("Search to <fontcolor= ' red ' >" &Counter& "</font> results")
Endfunction
' *************** Calendar files and folders ******************************
Privatefunctiongetallfile (Folder)
Dimobjfd,objfs,objff
Setobjfd=objfso.getfolder (Folder)
Setobjfs=objfd.subfolders
Setobjff=objfd.files
' Calendar subfolders
Dimstrfdname ' declares subfolder name
' ********* Calendar subfolders
Onerrorresumenext
Foreachonedirinobjfs
Strfdname=onedir.name
' System folders are not listed in the calendar
Ifstrfdname<> "Config.msi" eqvstrfdname<> "recycled" eqvstrfdname<> "RECYCLER" EQVstrFdName< > "Systemvolumeinformation" Then
sfn=folder& "" &strfdname ' absolute path
Callgetallfile (SFN) ' calls recursion
EndIf
Next
Dimstrflname
' ********** Calendar file ********
Foreachonefileinobjff
Strflname=onefile.name
' Desktop.ini and Folder.htt hidden system files are not in the column range
Ifstrflname<> "Desktop.ini" eqvstrflname<> "Folder.htt" Then
fn=folder& "" &strflname
Counter=counter+coloron (FN)
EndIf
Next
'***************************
' Close each object instance
Setobjfd=nothing
Setobjfs=nothing
Setobjff=nothing
Endfunction
' ********************* generation matching pattern ***********************************
Privatefunctioncreatepattern (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
Endfunction
' ************************** search and color the keywords *************************
Privatefunctioncoloron (FileName)
Dimobjreg
Setobjreg=newregexp
Objreg.pattern=createpattern (keyword)
Objreg.ignorecase=true
Objreg.global=true
Retval=objreg.test (FileName) ' Conduct search test, paint and output if passed
Ifretvalthen
Output=objreg.replace (FileName, "<fontcolor= ' #FF0000 ' >$1</font>") ' Sets the display color of the keyword
' *************************** This section can modify the output according to the need ************************************
output= "<ahref= ' >" &OutPut& "</a><br/>"
Response.Write (output) ' output matches the result
' ************************************* modifiable partial end **************************************
Coloron=1 ' Number of Add counters
Else
Coloron=0
endif
Setobjreg=nothing
Endfunction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.