本文介绍了[已解决]在保存附件功能中,它是否将对象引用设置为未设置为对象的实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
protected void SaveAttachments(Int32 actRuleID)
{
if (gvAttachments.Rows.Count > 0)
{
if ((Session["FileDetail"].ToString() != ""))
{
string[] Records = Session["FileDetail"].ToString().Split('#');
byte[] fileContent;
FileStream fs;
BinaryReader br;
for (int i = 0; i < Records.Length; i++)
{
string[] arrRecords = Records[i].Split(',');
fs = new FileStream(arrRecords[2], FileMode.Open, FileAccess.Read);
br = new BinaryReader(fs);
fileContent = br.ReadBytes((int)fs.Length);
br.Close();
fs.Close();
Econnect.EEMS.ActRulesAttachments objAttachment = new Econnect.EEMS.ActRulesAttachments();
objAttachment.ActRuleID = actRuleID;
objAttachment.FileName = arrRecords[0].ToString();
objAttachment.FileFormat = arrRecords[3].ToString();
objAttachment.FileContent = fileContent;
context.ActRuleAttachments.Add(objAttachment);
context.SaveChanges();
}
}
}
}
推荐答案
这篇关于[已解决]在保存附件功能中,它是否将对象引用设置为未设置为对象的实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!