Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在数据表中存储图像_C#_Winforms - Fatal编程技术网

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));