I have a winforms application and I need to download files from a Sharepoint OneDrive directory. Currently, given my code below, I am able to read the file Title, but I can't find anything to help me with downloading the code using Microsoft.SharePoint.Client .
string username = "appuser@abcuseraccount.com";
String pwd = "x!@ex";
ClientContext context = new ClientContext("https://abcuser.sharepoint.com/Main/financial/");
SecureString password = new SecureString();
foreach (char c in pwd.ToCharArray())
{
password.AppendChar(c);
}
context.Credentials = new SharePointOnlineCredentials(username, password);
context.ExecuteQuery();
List docs = context.Web.Lists.GetByTitle("Financial Notes");
Web site = context.Web;
context.Load(site);
context.ExecuteQuery();
CamlQuery query = CamlQuery.CreateAllItemsQuery(100);
ListItemCollection items = docs.GetItems(query);
context.Load(items);
context.ExecuteQuery();
foreach (ListItem listItem in items)
{
MessageBox.Show(listItem["Title"].ToString());
}
How can I download the files to my local drive (without using LiveAccount auth)?