private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog obj = new OpenFileDialog();
obj.Filter = "ALL Files(*.*)|*.*";
obj.Multiselect = true;
//int index = obj.FileName.LastIndexOf("//");
//string aa = obj.FileName.Substring(index + 1);
string filename = "";
if (obj.ShowDialog() == DialogResult.OK)
{
foreach (string s in obj.FileNames)
{
int id = dataGridView1.RowCount;
int i = dataGridView1.Rows.Add();
filename = System.IO.Path.GetFileName(s);
dataGridView1[0, i].Value = id;
dataGridView1[1, i].Value = filename;
dataGridView1[2, i].Value = s;
dataGridView1[3, i].Value = filename;
dataGridView1[4, i].Value = filename;
}
}
}
上传多个文件,添加到DataGridView中,超经典!
最新推荐文章于 2023-05-29 20:37:55 发布