Click here to Skip to main content
15,921,463 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,
i need to seach string inside the asp.net file,i need to serch the particular string inside the file or not
is it possible how to do this ??


Thanks inadvance
Posted
Comments
ZurdoDev 20-Aug-12 10:43am    
Have you used a search tool? Maybe explain more of what you need.
pradeep manne 20-Aug-12 10:48am    
i want to search only on some particular class files only,instead of my whole website files.at run time but not using the search tool.
for example i need to search word and highlight the all words,
i need the file name also to be displyed on my search results section
ZurdoDev 20-Aug-12 11:10am    
What kind of files? When you say ASP.Net files I am thinking C# or .aspx files they are code files and the aspx will render html so I'm still confused as to what you actually need. Can you give a clear example?
pradeep manne 20-Aug-12 11:16am    
class files,.aspx.cs files
ZurdoDev 20-Aug-12 11:19am    
Your code will have to access the file system. I suppose you could just loop through the files on the drive and using the File object http://msdn.microsoft.com/en-us/library/system.io.file.aspx, use ReadAllText or something along those lines.

1 solution

I don't see why you want to write code in a web page that searches the code of your web site, but you can write recursive code from the top level of your web site and search for strings inside files, just with File.ReadAllText and string.Contains.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900