【发布时间】:2012-05-26 23:45:10
【问题描述】:
c#如何知道opendialog中选择了多少个文件?
【问题讨论】:
标签: c# file multi-select opendialog
c#如何知道opendialog中选择了多少个文件?
【问题讨论】:
标签: c# file multi-select opendialog
.FileNames 可能会保存所选项目的数量:)
【讨论】:
获取对话框中所有选定文件的文件名。
例如
foreach (String myfile in openFileDialog1.FileNames)
{
// here myfile represent your selected file name
}
【讨论】:
在 WinForms 中,查看 OpenFileDialogs FileNames 属性,它将保存所有选定的文件。在 WPF 中,使用 Files 属性。
【讨论】:
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
}
}
【讨论】:
Dim files() as String = IO.Directory.GetFiles(od.SelectedPath)
Dim Count as string = files.Length
【讨论】: