如何知道在c#中的opendialog中选择了多少个文件?
答案 0 :(得分:3)
.FileNames可能会保留所选项目的数量:)
答案 1 :(得分:3)
获取对话框中所有选定文件的文件名。
例如
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