int i = 0;
private void button3_Click(object sender, EventArgs e)
{
string[] images = Directory.GetFiles(“E:/Img/”, “*.jpg”, SearchOption.AllDirectories);
string[] filename = new string[images.Length];
for (int i = 0; i < images.Length; i++)
{
filename[i] = Path.GetFileName(images[i]);
textBox1.Text = filename[i++];
}
private void button3_Click(object sender, EventArgs e)
{
string[] images = Directory.GetFiles(“E:/Img/”, “*.jpg”, SearchOption.AllDirectories);
string[] filename = new string[images.Length];
for (int i = 0; i < images.Length; i++)
{
filename[i] = Path.GetFileName(images[i]);
textBox1.Text = filename[i++];
}
想实现按钮触发在文本框内显示文件夹内全部jpg文件,实际效果只显示最后一个,问一下怎么样修改
解决方案
20
private void button3_Click(object sender, EventArgs e) { string[] images = Directory.GetFiles("E:/Img/", "*.jpg", SearchOption.AllDirectories); textBox1.Text = ""; for (int i = 0; i < images.Length; i++) { var filename = Path.GetFileName(images[i]); textBox1.Text += filename + ";"; } }