[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]
Enables an application to explicitly request a larger quota size, in bytes.
Namespace:
System.IO.IsolatedStorage Assembly:
mscorlib (in mscorlib.dll)
Visual Basic (Declaration)
Public Function TryIncreaseQuotaTo ( _
newQuotaSize As Long _
) As Boolean
Dim instance As IsolatedStorageFile
Dim newQuotaSize As Long
Dim returnValue As Boolean
returnValue = instance.TryIncreaseQuotaTo(newQuotaSize)
public bool TryIncreaseQuotaTo(
long newQuotaSize
)
public:
bool TryIncreaseQuotaTo(
long long newQuotaSize
)
public function TryIncreaseQuotaTo(
newQuotaSize : long
) : boolean
Return Value
Type:
System..::.Boolean true if the new quota is accepted by the user, otherwise, false.
| Exception | Condition |
|---|
| IsolatedStorageException | The isolated store has been removed. |
| [ArgumentOutOfRangeException] | newQuotaSize is less than zero -or- newQuotaSize is less than or equal to the value of the Quota property. |
| ObjectDisposedException | The isolated store has been disposed. |
The new quota size must not be less than the current quota. Only quota increases are allowed.
This method must be called in the code for an event handler, such as for a button click event to increase the quota. When TryIncreaseQuotaTo is called, the host must present a dialog box to the user to approve the request to increase storage space on the local computer. If the user declines the request, this method returns false and the quota remains the same size.
The following example requests an increase in the quota size. This example is part of a larger example provided for IsolatedStorageFile class.
// 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.TryIncreaseQuotaTo(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.
}
}
' 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.TryIncreaseQuotaTo((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
Reference