共用方式為


SPBackupRestoreSettings.UpdateProgress Property

Gets or sets a value that specifies at what points the operation should report its progress.

Namespace:  Microsoft.SharePoint.Administration.Backup
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

Public Property UpdateProgress As Integer
    Get
    Set

Dim instance As SPBackupRestoreSettings
Dim value As Integer

value = instance.UpdateProgress

instance.UpdateProgress = value
public int UpdateProgress { get; set; }

Property Value

Type: System.Int32
A Int32, from 1 to 100, that represents, as a percentage interval of the whole operation, when the operation should report its progress.

Exceptions

Exception Condition
SPException

Caller has tried to set the property to 0.

ArgumentException

Caller has tried to set the property to a negative number.

- or -

Caller has tried to set the property to a value greater than 100.

Remarks

For example, if UpdateProgress is 5, then the operation reports when it is 5% complete, 10% complete, 15% complete, and so on until it is 100% complete.

Examples

The following example shows how to use the UpdateProgress property in a backup application. For the full example and a detailed discussion of it, see How to: Programmatically Back Up Content.

static void Main(string[] args)
{
    // Identify the location for the backup storage.
    Console.Write("Enter full UNC path to the directory where the backup will be stored:");
    String backupLocation = Console.ReadLine();
    
    // Create the backup settings.
    SPBackupSettings settings = SPBackupRestoreSettings.GetBackupSettings(backupLocation, "Full");

    // Identify the content component to backup.
    Console.Write("Enter name of component to backup (default is whole farm):");
    settings.IndividualItem = Console.ReadLine();
    
    // Set optional operation parameters.
    settings.IsVerbose = true;
    settings.UpdateProgress = 10;
    settings.BackupThreads = 10;

    // Create the backup operation and return its ID.
    Guid backup = SPBackupRestoreConsole.CreateBackupRestore(settings);

    // Ensure that user has identified a valid and unique component.
    SPBackupRestoreObject node = EnsureUniqueValidComponentName(settings, ref backup);

    // Ensure that there is enough space.
    Boolean targetHasEnoughSpace = false;
    if (node != null)
    {
        targetHasEnoughSpace = EnsureEnoughDiskSpace(backupLocation, backup, node);
    }

    // If there is enough space, attempt to run the backup.
    if (targetHasEnoughSpace)
    {
        // Set the backup as the active job and run it.
        if (SPBackupRestoreConsole.SetActive(backup) == true)
        {
            if (SPBackupRestoreConsole.Run(backup, node) == false)
            {
                // Report "error" through your UI.
                String error = SPBackupRestoreConsole.Get(backup).FailureMessage;
                Console.WriteLine(error);
            }
        }
        else
        {
            // Report through your UI that another backup
            // or restore operation is underway. 
            Console.WriteLine("Another backup or restore operation is already underway. Try again when it ends.");
        }

        // Clean up the operation.
        SPBackupRestoreConsole.Remove(backup);

        Console.WriteLine("Backup attempt complete. Press Enter to continue.");
        Console.ReadLine();
    }
}// end Main

See Also

Reference

SPBackupRestoreSettings Class

SPBackupRestoreSettings Members

Microsoft.SharePoint.Administration.Backup Namespace