C# (WINFORMS)运行起来后 出现GDI+一般性错误

luheng1090 2009-04-16 11:13:08
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 MainFormapp
{
public partial class AdminForm : Form
{
private int id = 0;
public AdminForm()
{
InitializeComponent();
}

private void AdminForm_Load(object sender, EventArgs e)
{
//全屏
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
getimg();
}

private void getimg()
{
IList<getimgsResult> il = new List<getimgsResult>();
List<Image> l = new List<Image>();
using (TempDataContext obj = new TempDataContext())
{
il = obj.getimgs().ToList();
foreach (getimgsResult item in il)
{
byte[] b = item.img.ToArray();
MemoryStream ms = new MemoryStream(b, 0, b.Length, true);
Image img = Image.FromStream((Stream)ms);
l.Add(img);


ms.Close();
}
}
this.pictureBox1.Image = l[0];
this.pictureBox2.Image = l[1];
this.pictureBox3.Image = l[2];
this.pictureBox4.Image = l[3];
this.pictureBox17.Image = l[4];
this.pictureBox18.Image = l[5];
this.pictureBox8.Image = l[6];
this.pictureBox7.Image = l[7];
this.pictureBox6.Image = l[8];
this.pictureBox5.Image = l[9];
this.pictureBox12.Image = l[10];
this.pictureBox11.Image = l[11];
this.pictureBox10.Image = l[12];
this.pictureBox20.Image = l[13];
this.pictureBox19.Image = l[14];
this.pictureBox9.Image = l[15];


}

private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}

private void 添加用户ToolStripMenuItem_Click(object sender, EventArgs e)
{
AdduserForm add = new AdduserForm();
add.ShowDialog();
}




private void button13_Click(object sender, EventArgs e)
{
this.openFileDialog1.ShowDialog();
}

private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
{
using(TempDataContext obj=new TempDataContext())
{
obj.setvideopath(this.openFileDialog1.FileName);
}
}

private void button1_Click(object sender, EventArgs e)
{
this.id = 1;
this.openFileDialog2.ShowDialog();
}
private void openFileDialog2_FileOk(object sender, CancelEventArgs e)
{
try
{
string path = this.openFileDialog2.FileName;
FileInfo fi = new FileInfo(path);
byte[] b = new byte[fi.Length];
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
fs.Read(b, 0, b.Length);
fs.Close();
using (TempDataContext obj = new TempDataContext())
{
try
{
obj.setimg(new System.Data.Linq.Binary(b), this.id);
}
catch (Exception)
{

MessageBox.Show("设置失败");
return;
}


}
MessageBox.Show("设置成功");
getimg();

}
catch (Exception)
{

MessageBox.Show("文件读取错误");
return;
}


}

private void button2_Click(object sender, EventArgs e)
{
this.id = 2;
this.openFileDialog2.ShowDialog();
}

private void button3_Click(object sender, EventArgs e)
{
this.id = 3;
this.openFileDialog2.ShowDialog();
}

private void button4_Click(object sender, EventArgs e)
{
this.id = 4;
this.openFileDialog2.ShowDialog();
}

private void button8_Click(object sender, EventArgs e)
{
this.id = 7;
this.openFileDialog2.ShowDialog();
}

private void button7_Click(object sender, EventArgs e)
{
this.id = 8;
this.openFileDialog2.ShowDialog();
}

private void button6_Click(object sender, EventArgs e)
{
this.id = 9;
this.openFileDialog2.ShowDialog();
}

private void button18_Click(object sender, EventArgs e)
{
this.id = 5;
this.openFileDialog2.ShowDialog();
}

private void button19_Click(object sender, EventArgs e)
{
this.id = 6;
this.openFileDialog2.ShowDialog();
}

private void button5_Click(object sender, EventArgs e)
{
this.id = 10;
this.openFileDialog2.ShowDialog();
}

private void button12_Click(object sender, EventArgs e)
{
this.id = 11;
this.openFileDialog2.ShowDialog();
}

private void button11_Click(object sender, EventArgs e)
{
this.id = 12;
this.openFileDialog2.ShowDialog();
}

private void button10_Click(object sender, EventArgs e)
{
this.id = 13;
this.openFileDialog2.ShowDialog();
}

private void button21_Click(object sender, EventArgs e)
{
this.id = 14;
this.openFileDialog2.ShowDialog();
}

private void button20_Click(object sender, EventArgs e)
{
this.id = 15;
this.openFileDialog2.ShowDialog();
}

private void button9_Click(object sender, EventArgs e)
{
this.id = 16;
this.openFileDialog2.ShowDialog();
}
}
}

在线等啊。。。。 QQ78116846
...全文
68 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
kkun_3yue3 2009-04-16
  • 打赏
  • 举报
回复
给保存文件的路径添加写权限
jwdream2008 2009-04-16
  • 打赏
  • 举报
回复
关注中.......!
kkun_3yue3 2009-04-16
  • 打赏
  • 举报
回复
哪一行报错
luheng1090 2009-04-16
  • 打赏
  • 举报
回复
我图片都是保存在数据库的

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧