public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
ShowPictrue();
}
Image img = null;
int index = 0; string [] path =System.IO.Directory.GetFiles(Application.StartupPath + "\\image\\");
private void ShowPictrue()
{
foreach (string p in path)
{
img = Image.FromFile(p);//为什么会说内存不够?要有足够的内存
imageList1.Images.Add(img);
}
this.pictureBox1.Image = imageList1.Images[0];
}
}
请大家帮我看看为什么编译器不让遍历path,我想把 应用程序\\image\\路径下的文件名存到PATH中,
然后在把这些文件依次放到imageList1中,并在pictureBox1中显示
{
public Form1()
{
InitializeComponent();
ShowPictrue();
}
Image img = null;
int index = 0; string [] path =System.IO.Directory.GetFiles(Application.StartupPath + "\\image\\");
private void ShowPictrue()
{
foreach (string p in path)
{
img = Image.FromFile(p);//为什么会说内存不够?要有足够的内存
imageList1.Images.Add(img);
}
this.pictureBox1.Image = imageList1.Images[0];
}
}
请大家帮我看看为什么编译器不让遍历path,我想把 应用程序\\image\\路径下的文件名存到PATH中,
然后在把这些文件依次放到imageList1中,并在pictureBox1中显示
for (int i = 0; i < path.Length; i++)
{
if(path[i].Substring(path[i].LastIndexOf('.'),path[i].Length-path[i].LastIndexOf('.'))==".jpg")
{
Image image = Image.FromFile(path[i]);
list.Images.Add(image); }
}
pictureBox1.Image = list.Images[0];
我的好像可以啊
我刚就试了一下,要是不是图片文件就会出现内存不够的错误
我推测一下应该是Thumbs.db