views:

41

answers:

2

With this code I can have Silverlight ask the user if he wants to increase IsolatedStorage:

private void Button_IncreaseIsolatedStorage_Click(object sender, RoutedEventArgs e)
{
    IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication();
    long newStorageCapacityInBytes = FileHelpers.GetMaxiumumSpace() + SystemHelpers.GetAmountOfStorageToIncreaseWhenNeededInBytes();
    store.IncreaseQuotaTo(newStorageCapacityInBytes);
    Message = "IsolatedStorage increased. " + FileHelpers.GetSpaceLeftMessage();
}

But if I try to set it to an amount less than it current is, I get an error that this is not possible.

  1. Is there a workaround for this, i.e. can I reduce the amount of IsolatedStorage? This would be useful for testing purposes at least.

  2. Related question: When the user agrees to increasing IsolatedStorage, can other applications use this capacity or just the application in which he increased it? I assume this is the reason the above limitation is there.

+2  A: 

Since the Increase is performed on an IsolatedStorage File, only your application (or others hosted in your domain) can use the new quota:

Since isolated stores are scoped to particular assemblies, most other managed code will not be able to access your code's data (highly trusted managed code and administration tools can access stores from other assemblies). Unmanaged code can access any isolated stores.

Also, it seems that once you increase, you cannot go back (programmatically):

An application shares its quota with all other applications that are hosted on the same domain (Web site). The initial quota is 1 MB to be shared by all of the domain's applications. The new quota size must not be less than the current quota. Only quota increases are allowed.

http://msdn.microsoft.com/en-us/library/system.io.isolatedstorage.isolatedstoragefile.increasequotato%28v=VS.95%29.aspx

Bobby
A: 

The only way to reduce IsolatedStorage once allocated is to delete a sites IsolatedStorage using the Silverlight Configuration dialog. You can't do this programmatically the user has to open the configuration dialog and deliberately choose to delete the sites storage.

The quota is allocated to the site so yes when one application requests the quota to be increased other applications in the site may allocate space from that quota.

AnthonyWJones