Increase Isolated Storage Quota in Silverlight

Silverlight provides a mechanism called Isolated Storage to store data on the client computer. This mechanism is provided to ensure a safe browsing experience, as your application cannot directly access the user’s local file system. So in order to persist data like application state or user settings/preferences, you use a virtual file system called Isolated Storage.

The default quota for isolated storage is 1MB. However for Silverlight Out-Of-Browser applications, the default quota is 25MB. If you are making use of the Isolated Storage very frequently, you may find that even 25 MB is not sufficient.

The good part is that you can increase these limits if the user approves it. This is done by calling the IncreaseQuotaTo method of the IsolatedStorageFile class. Let us see how

First add a reference to the System.IO.IsolatedStorage namespace. Now write the following code on a button click event

// Increase Isolates Storage by
private void btnIncreaseIso_Click(object sender, RoutedEventArgs e)
using (IsolatedStorageFile isof = IsolatedStorageFile
Int64 freeSpace = isof.AvailableFreeSpace;
Int64 needSpace = 20971520; // 20 MB in bytes
if (freeSpace < needSpace)
if (!isof.IncreaseQuotaTo(isof.Quota + needSpace))
MessageBox.Show("User rejected increase space request");
MessageBox.Show("Space Increased");

First a store isolated for user is retrieved in the isof variable. The IncreaseQuotaTo method accepts a parameter which takes the number of bytes you want to increase. When the user clicks the button, Silverlight displays a message box which shows the current usage of the application in the isolated storage and the new size requested

Silverlight Isolated Storage

If the user clicks Yes, the size is increased.

About The Author

Suprotim Agarwal
Suprotim Agarwal, Developer Technologies MVP (Microsoft Most Valuable Professional) is the founder and contributor for DevCurry, DotNetCurry and SQLServerCurry. He is the Chief Editor of a Developer Magazine called DNC Magazine. He has also authored two Books - 51 Recipes using jQuery with ASP.NET Controls. and The Absolutely Awesome jQuery CookBook.

Follow him on twitter @suprotimagarwal.

No comments: