Hi, I am trying to search for files in a folder/Directory using C#.Net using Visual studio 2008 and sql server. All i want is that i need to find the word files in directory using textbox and button on button click all the files has to display with the keyword mentioned in the textbox i tried with the this code but i am getting the display in the same page i need the display in another page how can i do this please can anyone help me with this?
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 + "<br>");
for (int i = 0; i < numFiles; i++)
{
string file = files[i].ToString();
int file1 = file.IndexOf(search1,StringComparison.CurrentCultureIgnoreCase);
if (file1 != -1)
{
Response.Write("<br>" + file);
//Response.Write("<div style='position:absolute;top:" + file + "px;left:" + "px'>"+file! + "</div>");
Flag = 1;
}
}
if (Flag == 0)
{
Response.Write("No Matches Found");
}
}