I am looking for a way to update the one drive file or document using some SharePoint CSOM code. So can we achieve this using CSOM or some C# code?
I have even tried to load one drive site collection URL using the below code but I am not able to find the actual list from where I can access the stored files from one drive.
One Drive Site URL : https://{tenant}.my.sharepoint.com/personal/pravin_{tenant}_com
using (ClientContext clientcontext = new ClientContext(ConfigurationManager.AppSettings["SiteUrl"]))
{
Web web = clientcontext.Web;
clientcontext.Load(clientcontext.Web.Lists);
clientcontext.ExecuteQuery();
foreach (List list in clientcontext.Web.Lists)
{
var items = list.GetItems(CamlQuery.CreateAllItemsQuery());
clientcontext.Load(items);
clientcontext.ExecuteQuery();
foreach (var docItem in items)
{
//Here, I want to update the one drive file and upload it again using some sort of code.
}
}
}
Please suggest the code or other ways using which we can update the one drive files programmatically.
Please help. Thanks in Advance.