Showing posts with label Download Sharepoint Attachment. Show all posts
Showing posts with label Download Sharepoint Attachment. Show all posts

Thursday, October 6, 2011

Retrieve Sharepoint List Attachment programatically...

There is two was you can achieve this:

1.
foreach (string fileName in item.Attachments)
  {
    SPFile file = item.ParentList.ParentWeb.GetFile(
      item.Attachments.UrlPrefix + fileName);
  }



2. 

       SPListItem item = itemColl[0];
       SPFolder folder = ReferenceWeb.Folders["Lists"].SubFolders["Shared Assumption                  Translations"].SubFolders["Attachments"].SubFolders[item.ID.ToString()];
                            foreach (SPFile file in folder.Files)
                            {
                                byte[] binFile = file.OpenBinary();
                                memStr.Write(binFile, 0, binFile.Length);
                            }