Hi I am having a requirement to download files from doc library using c# console app. the below is the code I use.
ClientContext context = new ClientContext("https://siteurl");
context.Credentials = new NetworkCredential("userid", "password", "domain");
context.Load(context.Web);
List list = context.Web.Lists.GetByTitle("document library");
context.Load(list);
context.ExecuteQuery();
CamlQuery query = new CamlQuery();
query.ViewXml = "<view/>";
ListItemCollection licoll = list.GetItems(query);
context.Load(licoll);
context.ExecuteQuery();
foreach(ListItem li in licoll)
{
Microsoft.SharePoint.Client.File file = li.File;
if(file!=null)
{
//how to code this block to download the file?
}
}
how to download the file selected?