Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
Silverlight
 AvailableFreeSpace Property
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Silverlight

Other versions are also available for the following:
.NET Framework Class Library for Silverlight
IsolatedStorageFile..::.AvailableFreeSpace Property

Gets a value that represents the amount of free space available for isolated storage.

Namespace:  System.IO.IsolatedStorage
Assembly:  mscorlib (in mscorlib.dll)
Visual Basic (Declaration)
Public ReadOnly Property AvailableFreeSpace As Long
C#
public long AvailableFreeSpace { get; }

Property Value

Type: System..::.Int64
The available free isolated storage space, in bytes.
ExceptionCondition
IsolatedStorageException

The isolated store has been removed.

-or-

Isolated storage is disabled.

ObjectDisposedException

The isolated store has been disposed.

This property obtains the value from the store's associated quota group. Because the quota could change, the value cannot be cached in memory and must be read directly from the disk each time.

The following example checks the available free space to determine whether to increase the quota size. This example is part of a larger example provided for IsolatedStorageFile class.

Visual Basic
' Assumes an event handler for the MouseLeftbuttonUp
' event is defined for a control named 'IncreaseQuota'
' In the control's XAML: MouseLeftButtonUp="IncreaseQuota_OnLeftMouseButtonUp"
Public Sub IncreaseQuota_OnClick(ByVal sender As Object, ByVal e As MouseEventArgs)
    ' Obtain an isolated store for an application.
    Try
        Using store As IsolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication()
            ' Request 5MB more space in bytes.
            Dim spaceToAdd As Int64 = 5242880
            Dim curAvail As Int64 = store.AvailableFreeSpace
            ' If available space is less than
            ' what is requested, try to increase.
            If (curAvail < spaceToAdd) Then
                ' Request more quota space.
                If Not store.IncreaseQuotaTo((store.Quota + spaceToAdd)) Then
                    ' The user clicked NO to the
                    ' host's prompt to approve the quota increase.
                Else
                    ' The user clicked YES to the
                    ' host's prompt to approve the quota increase.
                End If
            End If
        End Using
    Catch Ex As IsolatedStorageException

        ' TODO: Handle that store could not be accessed.
    End Try
End Sub
C#
// Assumes an event handler for the MouseLeftbuttonUp
// event is defined for a control named 'IncreaseQuota'
// In the control's XAML: MouseLeftButtonUp="IncreaseQuota_OnLeftMouseButtonUp"

// User first selects UI to increase the quota.
public void IncreaseQuota_OnClick(object sender, MouseEventArgs e)
{

    // Obtain an isolated store for an application.
    try
    {
        using (var store = IsolatedStorageFile.GetUserStoreForApplication())
        {
            // Request 5MB more space in bytes.
            Int64 spaceToAdd = 5242880;
            Int64 curAvail = store.AvailableFreeSpace;

            // If available space is less than
            // what is requested, try to increase.
            if (curAvail < spaceToAdd)
            {

                // Request more quota space.
                if (!store.IncreaseQuotaTo(store.Quota + spaceToAdd))
                {
                    // The user clicked NO to the
                    // host's prompt to approve the quota increase.
                }
                else
                {
                    // The user clicked YES to the
                    // host's prompt to approve the quota increase.
                }
            }
        }
    }

    catch (IsolatedStorageException)
    {
        // TODO: Handle that store could not be accessed.

    }
}

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker