Hello guy's can any body help me about a assignment given to us by our proof. I'm new to programming but I'm learning via Google, but upon searching in Google i can't seem to find my question so I'm using the platform as the last resort. But first things first pls Bare with me for my bad English...
Ty for the help
FolderBrowserDialog<\/code><\/a>
<\/h2>
lets say Button, FolderBrowserDialog and ListView
<\/h2>Use any of the code below that suites your requirements:
<\/li><\/h3><\/li><\/ul>
Used FileInfo<\/code><\/a> class to access the files in the directory and access their names.
<\/h3><\/li><\/ul> Used DirectoryInfo<\/code><\/a> class to read Subdirectories inside a folder and access their names.
<\/h3><\/li><\/ul> Used FileSystemInfo<\/code><\/a> class to query each file and directory and access their names.
<\/h1>
using System; using System.IO; using System.Windows.Forms; namespace ListViewDirectory { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { if (folderBrowserDialog1.ShowDialog()== DialogResult.OK) { DirectoryInfo dir = new DirectoryInfo(folderBrowserDialog1.SelectedPath); FileInfo[] files = dir.GetFiles(); foreach (FileInfo item in files) { listView1.Items.Add(item.Name); } } } } }<\/code><\/pre>
Output<\/h1>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.