【发布时间】:2011-06-05 17:15:19
【问题描述】:
我使用 OpenFileDialog 类来打开并显示选择的文件名。
List<string> paths;
private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
{
label1.Text = "Now you can save the file paths or remove them from the list above";
paths.Add(openFileDialog1.FileName);
listBox1.DataSource=paths ;//Only one file is displayed in the listbox
Refresh();
}
我希望用户选择几个文件并在我拥有的列表框中显示他选择的所有文件。问题是每次只显示一个文件路径。有趣的是,我认为每当我使用 pahts.Add 时,都会添加新文件名,但实际上并非如此!?!
【问题讨论】: