Welcome to MSDN Blogs Sign in | Join | Help

SharePoint : How to programmatically download attachments from the List Items

Note: The following is example code. It is not available in SharePoint SDK

  SPWeb web = new SPSite("http://karthickmain:8080/sites/test").OpenWeb();
  //Open List
  SPList list = web.Lists["ListName"];
  //Get the item
  SPListItem item = list.Items[1];
  //Get the folder
  SPFolder folder = web.Folders["Lists"].SubFolders[strListName].SubFolders["Attachments"].SubFolders[item.ID.ToString()];
  
  foreach(SPFile file in folder.Files)
  {
   byte[] binFile = file.OpenBinary();
   System.IO.FileStream fstream = System.IO.File.Create("c:\\MyDownloadFolder\\" + file.Name); 
   fstream.Write(binFile, 0, binFile.Length);
  }

Published Sunday, March 12, 2006 10:57 AM by Karthikeyan
Filed under:

Comments

# http://netvibes.com/

Wednesday, March 22, 2006 11:16 AM by TrackBack

# http://bloglines.com/myblogs_display?folder=8912282

Wednesday, March 22, 2006 11:17 AM by TrackBack
Anonymous comments are disabled
 
Page view tracker