Tutorial :Silverlight 4.0: How to increase quota in Isolated File Storage



Question:

Got this line of code here but its not working.

private void Button_Click(object sender, RoutedEventArgs e)      {          using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())          {              long newSpace = isf.Quota + 1523456786435;              try              {                  if (true == isf.IncreaseQuotaTo(newSpace))                  {                      Debug.WriteLine("success");                  }                  else                  {                      Debug.WriteLine("unsuccessful");                  }              }              catch (Exception ex)              {                    throw ex;              }          }      }  


Solution:1

I suggest you to remove all breakpoints and run it. I just copy the code from the article that you mentioned and it's working fine.

One more thing. if its not working then try with IE..

As you know, this code isf.IncreaseQuotaTo(newSpace) should be in user-initiated event. One dialog will be shown to user and user need to agree on increasing the space.


Solution:2

The request to increase the quota needs to come from a user-initiated event such as a key press or button click.

Refer to the remarks section: http://msdn.microsoft.com/en-us/library/system.io.isolatedstorage.isolatedstoragefile.increasequotato(VS.95).aspx


Solution:3

Using breakpoints will invalidate the User Initiated action which Silverlight requires in order to increase the storage quota and will not increase the size when the call is made. Remove the breakpoints as advised and see if that solves your problem.

Using Debug.Writeline shouldn't cause a problem though. I tested my working code with them and it fired just fine.

My code is lifted from here: http://msdn.microsoft.com/en-us/library/cc265154(VS.95).aspx

The section I've taken is the IncreaseQuota_OnClick and referenced that from my button.

There's some other good methods in there too.


Solution:4

Make sure you remove all the breakpoints before you execute your code. I was making the same mistake and as soon as I removed the breakpoints, the thing worked fine and I had managed to increase the size of IsolatedStorage successfully.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »