我正在尝试从目录加载 .JPEG 图像并ListBox
通过单击按钮将其加载到我已经实现的。但是,我需要拍摄这些图像并将它们放入PictureBox
. 有人可以指出我正确的方向吗?这就是我到目前为止所拥有的。
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
DirectoryInfo dinfo = new DirectoryInfo(@"C:\cake");
FileInfo[] Files = dinfo.GetFiles();
foreach (FileInfo file in Files)
{
listBox1.Items.Add(file.Name);
}
}
private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Add(@"C:\cake");
}
private void pictureBox1_Click(object sender, EventArgs e)
{
string[] x = System.IO.Directory.GetFiles(@"C:\cake", "*.jpeg");
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
for (int i = 0; i < x.Length; i++)
{
listBox1.Items.Add(x[i]);
}
}
}