Cet article a fait l’objet d’une traduction automatique. Pour afficher l’article en anglais, activez la case d’option Anglais. Vous pouvez également afficher le texte anglais dans une fenêtre contextuelle en faisant glisser le pointeur de la souris sur le texte traduit.

SPList.GetChanges - Méthode (SPChangeToken)

Returns a collection of changes starting from a particular point in the change log.

Espace de noms :  Microsoft.SharePoint
Assembly :  Microsoft.SharePoint (dans Microsoft.SharePoint.dll)

public SPChangeCollection GetChanges(
	SPChangeToken changeToken


Type : Microsoft.SharePoint.SPChangeToken

The starting date and time. To start at the beginning of the change log, set this value to une référence Null (Rien dans Visual Basic).

Valeur renvoyée

Type : Microsoft.SharePoint.SPChangeCollection
The changes that have occurred in the list since the date and time specified by changeToken.


changeToken refers to a time before the start of the current change log.

You can get an SPChangeToken object to pass as an argument to this method by extracting one from the ChangeToken property of the last change returned by a previous call to the GetChanges method. Or, you can use the SPChangeToken constructor to create a new change token.


By default, the change log retains data for 60 days. You can configure the retention period by setting the ChangeLogRetentionPeriod property.

The following example is a console application that demonstrates how to get all changes in the log. The program loops while getting changes in batches and breaks out of the loop when it retrieves a collection with zero members, signifying that it has reached the end of the list.

using System;
using Microsoft.SharePoint;

namespace Test
   class ConsoleApp
      static void Main(string[] args)
         using (SPSite siteCollection = new SPSite("http://localhost"))
            using (SPWeb webSite = siteCollection.OpenWeb())
               // Get a list.
               SPList list = webSite.Lists[0];

               int total = 0;
               SPChangeToken token = null;

               // Get the first batch of changes.
               SPChangeCollection changes = list.GetChanges(token);

               // Loop until we reach the end of the log.
               while (changes.Count > 0)
                  total += changes.Count;

                  // Go get another batch.
                  token = changes.LastChangeToken;
                  changes = list.GetChanges(token);

               Console.WriteLine("Total of {0:#,#} changes to {1} list", total, list.Title);
         Console.Write("\nPress ENTER to continue...");