怎样用C#把一个文件夹中的图片全部读取出来,然后点击下一张,能依次显示啊

 我来答
xiaoxi0228
2011-11-25 · 超过51用户采纳过TA的回答
知道小有建树答主
回答量:251
采纳率:0%
帮助的人:135万
展开全部
string[] imageFile = Directory.GetFiles(@"E:\image");
获取到这个目录的所有图片文件,然后放在数组中,然后点击下一张的时候取数组的第n个
比如 imageFile [0] 第一张 imageFile [10]第十一张
追问
那怎样从数组中读取图片啊?
追答
imageFile 是数组
读取就通过下标读取 imageFile [0] 第一张
imageFile [1] 第二张 imageFile [2] 第三张 楼主明白了吧
百度网友e1b1222
推荐于2017-09-17 · TA获得超过955个赞
知道小有建树答主
回答量:470
采纳率:66%
帮助的人:329万
展开全部
测试可用,不过具体的楼主还得仔细调试一下。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace MorePictures
{
public partial class Form1 : Form
{
private int ImageCount;
private List<string> ImagePaths = new List<string>();
private int nowCount = 0;
public Form1()
{
InitializeComponent();
}

private void pictureBox1_DoubleClick(object sender, EventArgs e)
{
if (nowCount < ImageCount)
{
this.pictureBox1.Image = Bitmap.FromFile(ImagePaths[nowCount]);
nowCount++;
}
}

private void Form1_Load(object sender, EventArgs e)
{
foreach (string Path in Directory.GetFiles(@"C:\Documents and Settings\Administrator\My Documents\My Pictures"))
{
ImagePaths.Add(Path);
}
if (ImagePaths.Count != 0)
{
ImageCount = ImagePaths.Count;
}
}
}
}
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式