visual-studio-2010sharepointsharepoint-2010custom-lists

How to retrieve attachement file From Custom list sharepoint2010?


I have create custom list..and submit Form data onto list by Visual webpart.but i have doubts when i have attach on the attachments of list. now a time to retrieve Data from custom list but how can i retrieve attachement file from list and easy to download by End user??? Plz anyone guard me


Solution

  • SPFolder folder = web.Folders["Lists"].SubFolders[list.Title].SubFolders["Attachments"].SubFolders[listitem.ID.ToString()];
    

    Then you can do:

    foreach (SPFile file in folder.Files)
    {
        // Do what you want to do with the file
    }