About Me

My photo
Muthupet, TamilNadu, India
SharePoint 2010

Thursday, November 1, 2012

Programmatically download documents from document library Sharepoint

Programmatically download documents from document library Sharepoint
Lets look the code to download documents from a Document Library

SPList currentLib = web.Lists["LibraryName"];

Get all items from the document library

foreach (SPListItem item in items)
{

byte[] binfile = item.File.OpenBinary();

FileStream fstream = new FileStream("C:\\" + item.File.Name,
FileMode.Create, FileAccess.ReadWrite);

fstream.Write(binfile, 0, binfile.Length);

fstream.Close();
}

No comments:

Post a Comment