Hi All,
Is there a way of saving a System.Net.Attachment directly into a database field without writing to disk?
I am using LINQ and this is what I have for now:
AttachmentDetail attd = new AttachmentDetail();
attd.HeaderID=atth.ID;
attd.FileName = att.ContentDisposition.FileName;
attd.Object = ? //Something to put here...
Thanks and Regards
Saving System.Net.Attachment into Database
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Glenn Sanchez30 reputationPosted Mar 26, 2012, 11:48 PM EDT
AttachmentDetail attd = new AttachmentDetail();
attd.HeaderID=atth.ID;
attd.FileName = att.ContentDisposition.FileName;
byte[] data = new byte[att.ContentStream.Length];
att.ContentStream.Read(data,0,Convert.ToInt32(att.ContentStream.Length));
attd.Object = data.ToArray();
I can only confirm after I finish the thread that translates these attachments to a file.
regards
Glenn Sanchez30 reputationPosted Mar 27, 2012, 3:34 AM EDT