0

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.

0

The file is stored in the List Documents.

List list = clientcontext.Web.Lists.GetByTitle("Documents");
clientcontext.Load(list);
clientcontext.ExecuteQuery();
list.GetItems(CamlQuery.CreateAllItemsQuery());
| improve this answer | |
  • Thank you so much. It worked for me. – Pravin Durgam Sep 8 at 13:35
  • If my reply helps you, you could accept it as answer. – Michael Han_MSFT Sep 9 at 1:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.