IBackupRestore.DiskSizeRequired Property

Gets the amount of disk space, in bytes, that is required to store a backup of the content represented by the IBackupRestore object.

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


ReadOnly Property DiskSizeRequired As ULong
Dim instance As IBackupRestore
Dim value As ULong

value = instance.DiskSizeRequired
ulong DiskSizeRequired { get; }

Property Value

Type: System.UInt64
An UInt64 that represents the size, in bytes, that is needed on the storage device to save the data.


The DiskSizeRequired property is read at runtime by the DiskSizeRequired() method. The latter method adds 1K bytes to the value returned and then adds in the values of all the DiskSizeRequired property of each of the child IBackupRestore objects.

Notes to Implementers

Your get accessor should retrieve and sum the size of the databases and files and the size of all BLOBs that are larger than 1K bytes. If all of these together total less than 1K bytes, the get accessor should return 0.

Do not include the size of any child objects that are themselves IBackupRestore objects. The size of the child IBackupRestore objects is added into the total size at run time, by the DiskSizeRequired() method. The size of the children would be added to the total twice if they were also added by the get accessor of their parent.

Most IBackupRestore classes that have child IBackupRestore classes are just containers and the DiskSizeRequired property of such classes returns 0. For example, SPFarm.DiskSizeRequired is always 0.


The following example sums the sizes of all the files in an array of FileInfo objects called FrontEndFiles which is itself populated from a collection of paths called FrontEndFilePaths that is declared elsewhere as a private field in the class.


Storing the collection of strings instead of storing the collection of FileInfo objects itself is an advantage if the class derives, directly or indirectly, from the SPPersistedObject class. The latter class can have persisting String members (and collections of them) but it cannot persist FileInfo object members.

public UInt64 DiskSizeRequired
        UInt64 total = 0;
        List<FileInfo> FrontEndFiles = new List<FileInfo>(NUMBER_OF_FILES_TO_BACK_UP);
        foreach (String path in FrontEndFilePaths)
            FileInfo file = new FileInfo(path);
        foreach (FileInfo file in FrontEndFiles)
            total = total + (UInt64)file.Length;
        return total;
Public ReadOnly Property DiskSizeRequired() As UInt64
        Dim total As UInt64 = 0
        Dim FrontEndFiles As New List(Of FileInfo)(NUMBER_OF_FILES_TO_BACK_UP)

        For Each path As String In FrontEndFilePaths
            Dim file As New FileInfo(path)
        Next path

        For Each file As FileInfo In FrontEndFiles
            total = total + CULng(file.Length)
        Next file

        Return total
    End Get
End Property

See Also


IBackupRestore Interface

IBackupRestore Members

Microsoft.SharePoint.Administration.Backup Namespace