Below code can be used to add attachment to list item.
using (SPSite site = new SPSite("http://SiteCollectionURL"))
using (SPWeb web = site.OpenWeb())
SPList list = web.Lists["MyListName"];
SPListItem newItem = list.GetItemById(id);
byte contents = null;
if (fileUpload.PostedFile != null && fileUpload.HasFile)
using (Stream fileStream = fileUpload.PostedFile.InputStream)
contents = new byte[fileStream.Length];
fileStream.Read(contents, 0, (int) fileStream.Length);
SPAttachmentCollection attachments = newItem.Attachments;
string fileName = Path.GetFileName(fileUpload.PostedFile.FileName);
To query SharePoint List or Document Library in specific Folder “ FolderServerRelativeUrl ” as part of the CAML Query Code Snippet ...
Recently, I stumbled upon a situation where I had Calendar list and I had provided custom save and cancel button. In List setting I had kep...
In order to call a web service in sandbox environment following steps should be followed. Note: Assuming you already have c...