protected void SearchButton_Click(object sender, EventArgs e) { string dir = @"D:\file path\"; //visibility true SearchResultPanel.Visible = true; try { //Set the current directory. Directory.SetCurrentDirectory(dir); //search all files in path string[] directoryEntries = Directory.GetFiles(dir, "*.*", SearchOption.AllDirectories); int fill = directoryEntries.Length - 1; //Total count of files & Decoration SearchResultPanel.Controls.Add(new LiteralControl("<br />")); Label leb = new Label(); SearchResultPanel.Controls.Add(new LiteralControl("The total files count: ")); leb.Text = directoryEntries.Length.ToString(); this.SearchResultPanel.Controls.Add(leb); SearchResultPanel.Controls.Add(new LiteralControl("<hr />")); //retriving the files in new labels for (int i = 0; i < fill; i++) { TextBox NewText = new TextBox(); NewText.BorderStyle = BorderStyle.NotSet; NewText.TextMode = TextBoxMode.MultiLine; NewText.Width = 444; NewText.Height = 40; //Convert the file entries to text NewText.Text = directoryEntries[i]; //new line SearchResultPanel.Controls.Add(new LiteralControl("<br />")); this.SearchResultPanel.Controls.Add(NewText); }//end of for }//end of try catch (DirectoryNotFoundException ex) { Console.WriteLine("The specified directory does not exist. {0}", ex); } }// end of SearchButton_Click() method
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)