I have one requirement, i.e. If i have one Website, So I want to search the content from all webpages. Some thing like this, For Example our ASP.net Website "Search ASP.NET" and Search button , so when user type some content and clicking on the search
button, i Want to show which page having This Content with Link button.
rwOpenTemplate.Read(); it returns Integer values. It is not returning String values. What i mean to say is rwOpenTemplate.Read(); will retruning No of lines in Pages, It is returning Text Values.
using (StreamReader sr = new StreamReader("C:\\Work\\list.txt"));
{
string contents = sr.ReadToEnd();
if (contents.Contains(args[0]))
{
// ...
}
}
Or:
string contents = File.ReadAllText("C:\\Work\\list.txt");
if (contents.Contains(args[0]))
{
// ...
}
Alternatively, you could read it line by line:
foreach (string line in File.ReadLines("C:\\Work\\list.txt"))
{
if (line.Contains(args[0]))
{
// ...
// Break if you don't need to do anything else
}
}
Or even more LINQ-like:
if (File.ReadLines("C:\\Work\\list.txt").Any(line => line.Contains(args[0]))
{
...
}
Plz click Answer..if it suits your need
Marked as answer by Chen Yu - MSFT on Nov 28, 2012 08:00 AM
Parasala Mad...
Member
39 Points
37 Posts
Search Content throught out webPages
Nov 21, 2012 09:32 AM|LINK
Hi All,
I have one requirement, i.e. If i have one Website, So I want to search the content from all webpages. Some thing like this, For Example our ASP.net Website "Search ASP.NET" and Search button , so when user type some content and clicking on the search button, i Want to show which page having This Content with Link button.
Thanks in Advance,
Regards,
Parasala Madhu
manjuby
Participant
1131 Points
251 Posts
Re: Search Content throught out webPages
Nov 21, 2012 09:45 AM|LINK
You use below code and change as per your need...Use Files and place each files of your folder into template variable
Template = "filename";
string searchstring="search";
String line;
using (StreamReader rwOpenTemplate = new StreamReader(Template))
{
while (!rwOpenTemplate.EndOfStream)
{
line=rwOpenTemplate.Read();
(if line==searchstring)
Label1.Text="the text is in "+template;
}
}
Parasala Mad...
Member
39 Points
37 Posts
Re: Search Content throught out webPages
Nov 21, 2012 10:10 AM|LINK
Hi Manju,
rwOpenTemplate.Read(); it returns Integer values. It is not returning String values. What i mean to say is rwOpenTemplate.Read(); will retruning No of lines in Pages, It is returning Text Values.
manjuby
Participant
1131 Points
251 Posts
Re: Search Content throught out webPages
Nov 21, 2012 10:45 AM|LINK
Parasala Mad...
Member
39 Points
37 Posts
Re: Search Content throught out webPages
Nov 21, 2012 11:34 AM|LINK
Can u send me complete code for this. If there is any link , Send me that link also. Make it Fast Plz.....
alankarp
Contributor
2042 Points
345 Posts
Re: Search Content throught out webPages
Nov 21, 2012 11:38 AM|LINK
Hi,
If you want to search the content with in website. you can use "google custom search"
http://www.google.com/cse/
http://forums.asp.net/t/1560014.aspx/1
http://www.codeproject.com/Articles/16140/Using-Google-Co-op-s-Custom-Search-Engine
It is very much easy to implement.
Thanks
Alankar
Profile
manjuby
Participant
1131 Points
251 Posts
Re: Search Content throught out webPages
Nov 21, 2012 11:41 AM|LINK
using (StreamReader sr = new StreamReader("C:\\Work\\list.txt"));
{
string contents = sr.ReadToEnd();
if (contents.Contains(args[0]))
{
// ...
}
}
Or:
string contents = File.ReadAllText("C:\\Work\\list.txt");
if (contents.Contains(args[0]))
{
// ...
}
Alternatively, you could read it line by line:
foreach (string line in File.ReadLines("C:\\Work\\list.txt"))
{
if (line.Contains(args[0]))
{
// ...
// Break if you don't need to do anything else
}
}
Or even more LINQ-like:
if (File.ReadLines("C:\\Work\\list.txt").Any(line => line.Contains(args[0]))
{
...
}