Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to display the selected picture in listview and display filename,path and type

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the knowledge of "how to display the selected pictures in listview and display filename,path and type". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The copy code is as follows:

If (openFileDialog1.ShowDialog () = = DialogResult.OK)

{

ListView1.Items.Clear ()

String [] files = openFileDialog1.FileNames; / / define an array to get the selected file

String [] fileinfo = new string [3]; / / define an array to store file information

For (int I = 0; I < files.Length; iTunes +) / / traverses the file array

{

String path = Files [I] .ToString (); / / get the file path

/ / intercept the file name

String fileName = path.Substring (path.LastIndexOf ("\") + 1, path.Length-1-path.LastIndexOf ("\"))

/ / intercept file types

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)

}

}

Note: ListView1, View attribute is Details

The OpenFileDialog1,Multiselect property is true

This is the end of the content of "how to display the selected picture in listview and display filename,path and type". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report