below is the code
protected void Unnamed2_Click(object sender, EventArgs e)
{
string search1 = TextBox1.Text;
string[] files = Directory.GetFiles(@"D:\folder", "*.*", SearchOption.AllDirectories);
int Flag = 0;
string dir = @"D:\folder";
string[] files1;
int numFiles;
//files1 = Directory.GetFiles(dir);
numFiles = files.Length;
Response.Write("Files searched : " + numFiles + "
");
");
for (int i = 0; i < numFiles; i++)
{
string file = files[i].ToString();
int file1 = file.IndexOf(search1,StringComparison.CurrentCultureIgnoreCase);
if (file1 != -1)
{
Response.Write("
" + file);
" + file);
//Response.Write("
"+file! + "
"); Flag = 1;
}
}
if (Flag == 0)
{
Response.Write("No Matches Found");
}
}

Sukesh MarlaRank #461 · 5.4K reputationPosted Oct 31, 2012, 8:42 AM EDT
1 Create a Page2.aspx
and write whatever you have written in Unnamed2_Click of page1.aspx in Page Load of Page2.aspx
2)In Unnamed2_Click
Response.Redirect("Page2.aspx?SearchValue="+TextBox1.Text);
3)Replace this line
string search1 = TextBox1.Text;
with
string search1 = Request.Querystring["SearchValue"];
Check this is correct answer if it helped.
Asha Raju9 reputationPosted Nov 5, 2012, 11:00 PM EST
i tried exactly how you have said but i am getting an error can you pleaase help me with this.
Value cannot be null.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Parameter name: value
Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: value
Source Error:
Line 34: string file = files[i].ToString(); Line 35: Line 36: int file1 = file.IndexOf(search1, StringComparison.CurrentCultureIgnoreCase); Line 37: Line 38: if (file1 != -1)Source File: C:\Users\klausdev05\Documents\Visual Studio 2008\Projects\Search Engine\Search Engine\Page2.aspx.cs Line: 36
Riddhi ValechaRank #794 · 2.9K reputationPosted Nov 6, 2012, 12:03 AM EST
I think this search engine will give you better results if you do it in silverlight and linq.
I have attached my code....
Hope it helps you out....