FolderBrowserDialog fbd = new FolderBrowserDialog();
fbd.SelectedPath = "";
DialogResult result= fbd.ShowDialog();
if (result == DialogResult.Cancel)
{
return;
}
string path = "";
path = fbd.SelectedPath.ToString();
DirectoryInfo dir = new DirectoryInfo(path);
dataGridView1.DataSource = dir.GetFiles("*.mdf");
for (int i = 0; i < dataGridView1.RowCount; i++)
{
path = dataGridView1.Rows[i].Cells["Fullname"].Value.ToString();
this.listBox1.Items.Add(path);
}
txtpath.Text = fbd.SelectedPath.ToString(); |