Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Ruft den Speicherplatzbedarf für die Sicherung von den angegebenen Knoten (und dessen untergeordnete Elemente) in der Struktur der Komponenten in der angegebenen Sicherungsvorgang.
Namespace: Microsoft.SharePoint.Administration.Backup
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'Declaration
Public Shared Function DiskSizeRequired ( _
id As Guid, _
node As SPBackupRestoreObject _
) As ULong
'Usage
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
)
Parameter
id
Typ: System.GuidDie Guid -ID von der SPBackupRestoreConsoleObject , die den Sicherungsvorgang darstellt.
node
Typ: Microsoft.SharePoint.Administration.Backup.SPBackupRestoreObjectDie SPBackupRestoreObject , die die Komponente, die gesichert werden würde darstellt, wenn der identifizierten id -Vorgang fortgesetzt wird.
Rückgabewert
Typ: System.UInt64
Eine UInt64 , die den Abstand in Bytes, die für den Sicherungsvorgang benötigt darstellt.
Hinweise
Die DiskSizeRequired -Methode werden die Werte DiskSizeRequired aller Objekte, die in den Sicherungsvorgang enthalten summiert. Außerdem wird 1 KB, um sicherzustellen, dass sie immer mindestens 1 K zurückgibt, hinzugefügt.
Wenn MaxValue() zurückgegeben wird, enthält id keiner gültigen backup-Objekts.
Beispiele
Das folgende Beispiel zeigt die DiskSizeRequired -Methode verwendet wird, um festzustellen, ob das Sicherungs-Volume genügend Speicherplatz für die Komponenten zu sichernden verfügt. Das vollständige Beispiel und eine ausführliche Erläuterung des es finden Sie unter 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