Tuesday, 18 February 2014

Download files from splist

Download files from splist

private string DownloadAttachment(int NodeID)
{
string Attachment = string.Empty;
try
{
using (SPSite site = new SPSite(ConfigurationManager.AppSettings["SiteUrl"]))
{
using (SPWeb web = site.OpenWeb())
{
SPList myList = web.Lists["Articles"];
SPListItem attItem = myList.GetItemById(NodeID);


if (attItem["Attachments"] != null)
{
Attachment = attItem.Attachments.UrlPrefix.ToString() + attItem.Attachments[0].ToString();


return Attachment;
}
}

}


}
catch (Exception ex)

{

return Attachment;
}
return Attachment;
}

No comments:

Post a Comment