日期:2014-05-18 浏览次数:20877 次
ColumnHeader ch_FileName = new ColumnHeader(); ch_FileName.Text = "File Name"; ch_FileName.Width = 110; ColumnHeader ch_FileLocation = new ColumnHeader(); ch_FileLocation.Text = "File Path"; ch_FileLocation.Width = 110; listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[]{ ch_FileName, ch_FileName}); OpenFileDialog openFile = new OpenFileDialog(); if(openFile.ShowDialog() == DialogResult.OK) { foreach(string file in openFile.FileNames) { string fileName = System.IO.Path.GetFileNameWithoutExtension(file); ListViewItem item = new ListViewItem(new string[]{ fileName, file}); listView1.Items.Add(item); } }
------解决方案--------------------
楼上写的很清楚了,不过要再设置一下打开对话框多选。
openFile.Multiselect=true; //这样才可以多选文件