把照片写入到DataTable

if (mydtzybr.Columns.Contains("image1") == true && mydtzybr.Columns.Contains("imgfile") == true)
{
    string filename, filefull;
    for (int i = 0; i < mydtzybr.Rows.Count; i++)
    {
        filename = mydtzybr.Rows[0]["image1"].ToString();
        if (string.IsNullOrEmpty(filename) == false)
        {
            if (string.Compare(db_type, "db") == 0)
            {
                filefull = Application.StartupPath + @"\uploadfile\" + filename;
                if (System.IO.File.Exists(filefull) == true)
                {
                    try
                    {
                        mydtzybr.Rows[0]["imgfile"] = cwfIosys.ioCtrl.ReadFile(filefull);
                    }
                    catch (Exception cw)
                    {
                        appctrl.lastErrorlev = 2;
                        appctrl.lastError = cw.Message;
                        appctrl.WriteErrLog(cw.Message, "写入住院病人图像数据");
                        appctrl.appruninglog.addlog("写入住院病人图像数据失败!" + cw.Message);
                    }
                }
            }
        }
    }
    mydtzybr.AcceptChanges();
}

原文地址:https://www.cnblogs.com/cwfsoft/p/1760943.html