Partager via


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)

Syntax

ReadOnly Property DiskSizeRequired As ULong
    Get

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.

Remarks

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.

Examples

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.

Note

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
{
    get
    {
        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);
            FrontEndFiles.Add(file);
        }
        
        foreach (FileInfo file in FrontEndFiles)
        {
            total = total + (UInt64)file.Length;
        }
        
        return total;
    }
}

See Also

Reference

IBackupRestore Interface

IBackupRestore Members

Microsoft.SharePoint.Administration.Backup Namespace