1. Create a document library and enter the library settings. Find "Information management policy settings" and click to enter. For example, with:
2. Set "Document", "folder" two respectively. For example, with:
3, tick enable Auditing. For example, with:
4. Tick all the event, for example:
5, code. For example, the following:
Public Static voidGetdownloadnum (stringUrlstringSiteURL) {Spsecurity.runwithelevatedprivileges (Delegate() { using(SPSite site =NewSPSite (SiteURL)) { using(SPWeb Web =site. OpenWeb ()) {web. Allowunsafeupdates=true; Spauditquery Auditquery=NewSpauditquery (site); Auditquery.addeventrestriction (Spauditeventtype.view); Auditquery.restricttolistitem (web. GetFile (URL). Item); Spauditentrycollection auditentrycollection=web. Audit.getentries (Auditquery); Console.WriteLine (URL); Console.WriteLine ("Count:"+auditEntryCollection.Count.ToString ()); } } });}
6. Download a test document, execute the code, for example:
Summary
I've been hearing about the number of downloads of documents through audits. Try to feel good to use, but also see that there is a way to encapsulate their own definition of the field, or timerjob solution, feeling is a way of it, simple write open and call the way to everyone to participate in the test.
In particular, other event can be viewed in addition to the number of downloads. In addition to the audit information for list items, there is information about the list. You are interested in being able to try it yourself.
All right, here we go. Rest.
。
。
Have a rest ...
Documentation for references
Http://msdn.microsoft.com/en-us/library/bb466223.aspx
SharePoint 2013 Gets the number of document downloads through audits