Tuesday, May 17, 2011

How to programmatically download attachments from list items in Windows

SPWeb web = new SPSite("<Site URL>").OpenWeb(); SPList list = web.Lists["<ListName>"]; SPListItem item = list.Items[1]; 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); }

No comments:

Post a Comment

Thank you for Commenting Will reply soon ......

Featured Posts

#Linux Commands Unveiled: #date, #uname, #hostname, #hostid, #arch, #nproc

 #Linux Commands Unveiled: #date, #uname, #hostname, #hostid, #arch, #nproc Linux is an open-source operating system that is loved by millio...