Get the App
SLTechnology News&Howtos  ›  Development  › 

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

Shulou Source: shulou.com Published: 2022-06-03 07:38:33 10月05日 Update

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!

Tags: Files selections arrays pictures code content attributes more knowledge practicality learning next information names dilemmas facts situations articles cases comments Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Apple MySQL Linux macOS