views:

645

answers:

3

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;
            }
        }
    }
+2  A: 

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

X-Cubed
I already have a button and I place the above code in the click event.
xscape
This is just an utterly stupid restriction. I have written a caching mechanism that I now may have to scrap.Why would they choose to limit it to user-events, you really are not gaining anything from this.
Oliver
I agree, if you already have to ask for user permission using a dialog you can't touch, what's the point of this restriction?
andrecarlucci
+3  A: 

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.

Michael Sync
A: 

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.

Fellmeister

related questions