Tuesday 30 August 2011

How to 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();
}

Ads by Google

1 comment: