Add to Favorites    Make Home Page 17763 Online  
 Language Categories  
 Our Services  

Home » ASP Home » Files Home » Search Function

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title Search Function
Description The Search function recursively searches all files on a hard drive for a specific phrase from a specified start directory. The Search function is not meant for web site searches by site users but was designed to be used in code only to obtain the path of a file matching the given phrase. The Search function returns a string of absolute paths of all files containing the search phrase. Each path is separated by a carriage-return line-feed (vbCrLf) that is used as a delimiter. The Search function has two required arguments, phrase and directory. Phrase is a string representing these exact phrase or word grouping to search. Directory is the absolute path of the folder to begin recursively searching.
Category ASP » Files
Hits 6446
Code Select and Copy the Code
example usage: Search all files of the entire web site For the exact phrase "request.cookies" And delete them (also uses the kill statement). <% ' declare variables Dim a, b, i ' search the entire web site for the phrase "request.cookies" a = Search( "request.cookies", Server.MapPath("/") ) ' iterate the array of results b = Split(a , vbCrLf) For i = 0 To UBound(b) - 1 ' delete each matching page Kill b(i) Next %> source code: <% Private Function Search(ByVal phrase, ByVal directory) Dim objFSO, currentFolder, objFile, currentFile Dim strSearch, fileContents, objFolder Set objFSO = Server.CreateObject("Scripting.FileSystemObject") Set currentFolder = objFSO.GetFolder(directory) For Each objFile In currentFolder.Files If LCase( objFile.Path ) = _ LCase( Server.MapPath( _ Request.ServerVariables("SCRIPT_NAME") ) ) Then Else Set currentFile = _ objFSO.OpenTextFile( objFile.Path, 1, False ) fileContents = LCase( currentFile.ReadAll() ) currentFile.Close Set currentFile = Nothing If InStr( fileContents, phrase ) Then strSearch = strSearch & objFile.Path & vbCrLf Else strSearch = strSearch & "" End If End If Next For Each objFolder In currentFolder.SubFolders strSearch = strSearch & Search( phrase, objFolder ) Next Set currentFolder = Nothing Set objFSO = Nothing Search = CStr( strSearch ) End Function %>

Related Source Codes

Script Name Author
ııııııııııııııııııııı VyomWorld
Resistor color code reader A.Chermarajan.
Telephone Directory dhivya
card swapping game (Mini Project) nityanand
simple hangman-pascalsource Seabert
college dirtectory (Mini Project) msridhar
Poll Application John van Meter
ASP Daily Hit Counter. Tejaskumar Gandhi
To avoid null in asp environment using sql Sami
Maklumbalas webmaster
poll John van Meter
EasyASP Template Engine. TjoekBezoer
Basic Calculator using HTML & Javascript. Patrick M. D Souza
What servers support ASP ? VyomWorld
What is ASP? VyomWorld

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions
Copyright ©2003-2017 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=365


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review