using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.IO;namespace ListBox控件{ public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void Form2_Load(object sender, EventArgs e) { for (int i = 0; i < path.Length; i++) { string fileName = Path.GetFileName(path[i]); listBox1.Items.Add(fileName); } } string[] path = Directory.GetFiles(@"C:\Users\Administrator\Desktop\新建文件夹"); //双击播放图片 private void listBox1_DoubleClick(object sender, EventArgs e) { pictureBox1.Image = Image.FromFile(path[listBox1.SelectedIndex]); } }}