C# 在数据表中存储图像
我试图将图像存储在C# 在数据表中存储图像,c#,winforms,C#,Winforms,我试图将图像存储在datatble文件夹中,类似于下面的代码,我尝试了这段代码,但在我出错的地方它不起作用 private void ViewR_Load(object sender, EventArgs e) { String str = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string path = str + "\\image
datatble
文件夹中,类似于下面的代码,我尝试了这段代码,但在我出错的地方它不起作用
private void ViewR_Load(object sender, EventArgs e)
{
String str = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string path = str + "\\images\\";
DataTable dt1 = new DataTable();
dt1.Columns.Add("Images", System.Type.GetType("System.Drawing.Bitmap[]"));
if (System.IO.Directory.Exists(path))
{
string[] allImg = System.IO.Directory.GetFiles(path);
foreach (string imgName in allImg)
{
Image img = new Bitmap(imgName);
//row = dt1.NewRow();
dt1.Rows.Add(img.GetThumbnailImage(350, 350, null, new IntPtr()));
img.Dispose();
}
}
ds.Tables[1].Merge(dt1);
}
任何异常或错误消息?无symply控件不会继续执行此行
dt1.Columns.Add(“Images”,System.Type.GetType(“System.Drawing.Bitmap[])
我怀疑它应该是什么类型的“System.Drawing.Bitmap[]”
或其他一些我没有得到它我假设它应该是dt1.Columns.Add(“图像”,typeof(Bitmap[])
并检查目录和文件exist@SriramSakthivel我检查了目录exist derTry this dt1.Columns.Add(“Images”,typeof(Bitmap));