searchsanjaysharma
asked on
How to read the dirlisting into a array and store in grid.
I have an folder FileRepo: It contains files of the format.
AAAAK5389F1_FORM16A_2010-1 1_Q1.pdf
AAAAK5389F1_FORM16A_2010-1 1_Q2.pdf
AAAAK5389F1_FORM16A_2010-1 1_Q3.pdf
AAAAK5389F1_FORM16A_2010-1 1_Q4.pdf
AAAAK5389F2_FORM16A_2010-1 1_Q1.pdf
AAAAK5389F2_FORM16A_2010-1 1_Q2.pdf
AAAAK5389F2_FORM16A_2010-1 1_Q3.pdf
AAAAK5389F2_FORM16A_2010-1 1_Q4.pdf
The user enters the token no. which is common for file.ex. AAAAK5389F1
I want when the user enters this token no. in txttoken
The gridview should be filled with all files containing this token no. i.e
AAAAK5389F1_FORM16A_2010-1 1_Q1.pdf
AAAAK5389F1_FORM16A_2010-1 1_Q2.pdf
AAAAK5389F1_FORM16A_2010-1 1_Q3.pdf
AAAAK5389F1_FORM16A_2010-1 1_Q4.pdf
AAAAK5389F1_FORM16A_2010-1
AAAAK5389F1_FORM16A_2010-1
AAAAK5389F1_FORM16A_2010-1
AAAAK5389F1_FORM16A_2010-1
AAAAK5389F2_FORM16A_2010-1
AAAAK5389F2_FORM16A_2010-1
AAAAK5389F2_FORM16A_2010-1
AAAAK5389F2_FORM16A_2010-1
The user enters the token no. which is common for file.ex. AAAAK5389F1
I want when the user enters this token no. in txttoken
The gridview should be filled with all files containing this token no. i.e
AAAAK5389F1_FORM16A_2010-1
AAAAK5389F1_FORM16A_2010-1
AAAAK5389F1_FORM16A_2010-1
AAAAK5389F1_FORM16A_2010-1
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok
ASKER
Its giving System.IO.DirectoryNotFoun
protected void Button1_Click(object sender, EventArgs e)
{
var dt = new DataTable();
dt.Columns.Add("Name", typeof(string));
Directory.GetFiles("Files"
.ToList()
.ForEach(s =>
{
var dr = dt.NewRow();
dr.SetField<string>("Name"
dt.Rows.Add(dr);
});
if (dt.Rows.Count > 0)
{
GridView1.DataSource = dt;
GridView1.DataBind();
}
}