Monday, 21 April 2008

Silverlight 2 reducing Isolated Storage Quota

Now that I am back from holiday, it is time to blog a little.

I've been messing around with Isolated Storage for the past few days, and there is some interesting issues.

It seems to me i can increase the Isolated Storage quota (the amount of allocated isolated storage), but I don't seem to have anyway to reduce it (in the beta)?

The following code will ask the user permission to increase the quota to 1Mb (default starting quota is 100Kb)


using (IsolatedStorageFile userStore =
IsolatedStorageFile.GetUserStoreForApplication())
{
userStore.TryIncreaseQuotaTo(1048576);
}


which is all lovely and stuff, but I have no way to reduce the quota size in the future. The only way to mess with the quota is to use TryIncreaseQuotaTo, however if you attempt set the quota to a value less than your current quota, it throws an exception.

I also tried killing my isolated storage (to no avail):


using (IsolatedStorageFile userStore =
IsolatedStorageFile.GetUserStoreForApplication())
{
userStore.Remove();
}


I think it would be better if an exception was thrown if you attempted to reduce the quota below the used space (userStore.Quota - userStore.AvailableFreeSpace)

No comments: