Compartir a través de


(Guid, SPBackupRestoreObject) del método SPBackupRestoreConsole.DiskSizeRequired

Obtiene la cantidad de espacio en disco necesario para la copia de seguridad del nodo especificado (y sus elementos secundarios) en el árbol de componentes de la operación de copia de seguridad especificada.

Espacio de nombres:  Microsoft.SharePoint.Administration.Backup
Ensamblado:  Microsoft.SharePoint (en Microsoft.SharePoint.dll)

Sintaxis

'Declaración
Public Shared Function DiskSizeRequired ( _
    id As Guid, _
    node As SPBackupRestoreObject _
) As ULong
'Uso
Dim id As Guid
Dim node As SPBackupRestoreObject
Dim returnValue As ULong

returnValue = SPBackupRestoreConsole.DiskSizeRequired(id, _
    node)
public static ulong DiskSizeRequired(
    Guid id,
    SPBackupRestoreObject node
)

Parámetros

Valor devuelto

Tipo: System.UInt64
UInt64 que representa el espacio, en bytes, necesaria para la operación de copia de seguridad.

Comentarios

El método DiskSizeRequired suma los valores de DiskSizeRequired de todos los objetos incluidos en la operación de copia de seguridad. También se agrega 1K bytes para asegurarse de que siempre devuelve un mínimo de 1 KB.

Si se devuelve MaxValue() , id no contiene un objeto de copia de seguridad válido.

Ejemplos

En el ejemplo siguiente se muestra el método DiskSizeRequired se usa para determinar si el volumen de copia de seguridad tiene suficiente espacio para contener los componentes para realizar copias de seguridad. Para obtener una explicación detallada de la misma y el ejemplo completo, vea How to: Programmatically Back Up Content.

private static Boolean EnsureEnoughDiskSpace(String location, Guid backup, SPBackupRestoreObject node)
{
    UInt64 backupSize = SPBackupRestoreConsole.DiskSizeRequired(backup, node);
    UInt64 diskFreeSize = 0;
    UInt64 diskSize = 0;
    Boolean hasEnoughSpace = true;

    try
    {
        SPBackupRestoreConsole.DiskSize(location, out diskFreeSize, out diskSize);
    }
    catch
    {
        diskFreeSize = diskSize = UInt64.MaxValue;
    }

    if (backupSize > diskFreeSize)
    {
        // Report through your UI that there is not enough disk space.
        Console.WriteLine("{0} bytes of space is needed but the disk hosting {1} has only {2}.", backupSize, location, diskFreeSize);
        Console.WriteLine("Please try again with a different backup location or a smaller component.");
        hasEnoughSpace = false;
    }
    else if (backupSize == UInt64.MaxValue || diskFreeSize == 0)
    {
        // Report through your UI that it cannot be determined whether there is enough disk space.
        Console.WriteLine("Cannot determine if that location has enough disk space.");
        Console.WriteLine("Please try again with a different backup location or a smaller component.");
        hasEnoughSpace = false;
    }
    return hasEnoughSpace;

}// end EnsureEnoughDiskSpace
Private Shared Function EnsureEnoughDiskSpace(ByVal location As String, ByVal backup As Guid, ByVal node As SPBackupRestoreObject) As Boolean
    Dim backupSize As UInt64 = SPBackupRestoreConsole.DiskSizeRequired(backup, node)
    Dim diskFreeSize As UInt64 = 0
    Dim diskSize As UInt64 = 0
    Dim hasEnoughSpace As Boolean = True

    Try
        SPBackupRestoreConsole.DiskSize(location, diskFreeSize, diskSize)
    Catch
        diskSize = UInt64.MaxValue
        diskFreeSize = diskSize
    End Try

    If backupSize > diskFreeSize Then
        ' Report through your UI that there is not enough disk space.
        Console.WriteLine("{0} bytes of space is needed but the disk hosting {1} has only {2}.", backupSize, location, diskFreeSize)
        Console.WriteLine("Please try again with a different backup location or a smaller component.")
        hasEnoughSpace = False
    ElseIf backupSize = UInt64.MaxValue OrElse diskFreeSize = 0 Then
        ' Report through your UI that it cannot be determined whether there is enough disk space.
        Console.WriteLine("Cannot determine if that location has enough disk space.")
        Console.WriteLine("Please try again with a different backup location or a smaller component.")
        hasEnoughSpace = False
    End If
    Return hasEnoughSpace

End Function ' end EnsureEnoughDiskSpace

Vea también

Referencia

clase SPBackupRestoreConsole

Miembros SPBackupRestoreConsole

Sobrecarga DiskSizeRequired

Espacio de nombres Microsoft.SharePoint.Administration.Backup