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");
}
}
Riddhi ValechaPosted Nov 6, 2012, 5:03 AM
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....
Asha RajuPosted Nov 6, 2012, 4:00 AM
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:
Source File: C:\Users\klausdev05\Documents\Visual Studio 2008\Projects\Search Engine\Search Engine\Page2.aspx.cs Line: 36
Sukesh MarlaPosted Oct 31, 2012, 12:42 PM
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.