将图像存储在数据表中

时间:2013-09-28 09:28:26

标签: 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 + "\\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);
}

0 个答案:

没有答案