如何知道c#中opendialog中有多少个选定的文件?

时间:2012-05-19 21:18:01

标签: c# file multi-select opendialog

如何知道在c#中的opendialog中选择了多少个文件?

5 个答案:

答案 0 :(得分:3)

.FileNames可能会保留所选项目的数量:)

答案 1 :(得分:3)

FileDialog.FileNames Property

  

获取对话框中所有选定文件的文件名。

例如

foreach (String myfile in openFileDialog1.FileNames) 
{
  // here myfile represent your selected file name 
}

答案 2 :(得分:1)

在WinForms中,查看OpenFileDialogs FileNames属性,该属性将包含所有选定的文件。在WPF中,使用Files属性。

答案 3 :(得分:0)

 private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
 {
 openFileDialog1.Multiselect = true;
 }
 private void button1_Click(object sender, EventArgs e)
 {
 DialogResult result = openFileDialog1.ShowDialog();
 if (result == DialogResult.OK)
 {
 List<string> fff = openFileDialog1.FileNames.ToList();
 // Do something with the list
 }  
 }

答案 4 :(得分:-2)

Dim files() as String = IO.Directory.GetFiles(od.SelectedPath)
Dim Count as string = files.Length