Quantcast
Viewing all articles
Browse latest Browse all 10096

How to get all the files which is modified or added yesterday from SharePoint document library.

Hi All,

I am trying to get all the files which is modified or added yesterday from SharePoint document library using below code.

           

List list = clientContext.Web.Lists.GetByTitle(listName);
                clientContext.Load(list);
                clientContext.ExecuteQuery();
                CamlQuery camlQuery = new CamlQuery();
                camlQuery = new CamlQuery();
                camlQuery.ViewXml =
                    "<View Scope='Recursive'>"
                     + "  <Query>"
                     + "    <Where>"
                     + "    <Geq>"
                     + "    <FieldRef Name='Modified' />"
                     + "     <Value Type='DateTime' IncludeTimeValue='False'>"
                     + "      <Today OffsetDays='" + ConfigurationManager.AppSettings.Get("OffsetDays") + "' />"
                     + "     </Value>"
                     + "    </Geq>"
                     + "    </Where>"
                     + "  </Query>"
                     + "</View>";

                ListItemCollection listCol = list.GetItems(camlQuery);
                clientContext.Load(listCol);
                clientContext.ExecuteQuery();
                int cnt = listCol.Count;
                foreach (var item in listCol)
                {
                          TestingFiles(clientContext, item.FieldValues["FileDirRef"].ToString());
                }

Please note that the value of OffsetDays is -1.

But with the above code I am getting all the files instead only yesterdays files. Any idea what went wrong in my code.        Thanks in advance.



Viewing all articles
Browse latest Browse all 10096

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>