如何一次添加多个附件?

mjx2004 2010-10-27 03:46:51
现在的只能一次添加一个附件。

/*添加附件*/
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
openFileDialog1.Filter = "所有文件(*.*)|*.*";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string[] files = openFileDialog1.FileNames;
foreach (string file in files)
{
paths.Add(file);
t_files.Text += Path.GetFileName(file) + " ";
}
}
}
...全文
219 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuyq11 2010-10-27
  • 打赏
  • 举报
回复
Multiselect属性设置为true
OpenFileDialog openFileDialog1= new OpenFileDialog();
openFileDialog1.Multiselect = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string[] filesName = openFileDialog1.FileNames;
foreach (string info in filesName)
{
File f=new FileInfo(info);
}
}
air123456789 2010-10-27
  • 打赏
  • 举报
回复
把 openFileDialog1 的Multiselect属性设置为true 就能选择多个。

111,129

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧