Posts

Showing posts from April 3, 2015

Lamda Expression in Sharepoint SPListItemCollection

(lstEmpCertificationCol.Exists(x => x["UserName"].ToString() == ct.chkselectedUserNmae))

set attchment to a list in sharepoint 2013

if (ct.Attachment != null) { ct.DocumentName = ct.Attachment.ToString(); byte[] contents = GetFileStream(); if ((ct.DocumentName != null) && (contents.Length > 0)) { SPAttachmentCollection fileAttach = empCertificationitem.Attachments; if (ct.TemAttachmentName == System.IO.Path.GetFileName(ct.DocumentName)) { empCertificationitem.Attachments.Delete(System.IO.Path.GetFileName(ct.DocumentName)); fileAttach.Add(ct.DocumentName, contents); } else { fileAttach.Add(ct.DocumentName, content

Get Attachement From Sharepoint list

foreach (String attachmentname in tempEmpCerificationitem.Attachments) { Stream stream; ct.TemAttachmentName = attachmentname; String attachmentAbsoluteURLs = tempEmpCerificationitem.Attachments.UrlPrefix + attachmentname; // gets the containing directory URL // To get the SPSile reference to the attachment just use this code SPFile attachmentFile = ct.oweb.GetFile(attachmentAbsoluteURLs); // To read the file content simply use this code ct.stream= attachmentFile.OpenBinaryStream(); StreamRead