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