帝王谷资源网 Design By www.wdxyy.com

复制代码 代码如下:
if (openFileDialog1.ShowDialog() == DialogResult.OK)
           {
               listView1.Items.Clear();
               string[] files = openFileDialog1.FileNames; //定义一个数组,获取选择的文件
               string[] fileinfo = new string[3];  //定义一个数组,用于存储文件信息
               for (int i = 0; i < files.Length; i++)  //遍历文件数组
               {
                   string path = files[i].ToString();  //获取文件路径
                   //截取文件名字
                   string fileName = path.Substring(path.LastIndexOf("\\") + 1, path.Length - 1 - path.LastIndexOf("\\"));
                   //截取文件类型
                   string fileType = fileName.Substring(fileName.LastIndexOf(".") + 1, fileName.Length - 1 - fileName.LastIndexOf("."));
                   fileinfo[0] = fileName;
                   fileinfo[1] = path;
                   fileinfo[2] = fileType;
                   ListViewItem lvi = new ListViewItem(fileinfo);
                   listView1.Items.Add(lvi);

               }
          }

注释:ListView1, View 属性为Details

OpenFileDialog1,Multiselect属性为true

标签:
C#,listview,filename

帝王谷资源网 Design By www.wdxyy.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
帝王谷资源网 Design By www.wdxyy.com