xscape
xscape

Reputation: 3376

Silverlight 4.0: How to increase quota in Isolated File Storage

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;
            }
        }
    }

Upvotes: 1

Views: 8240

Answers (4)

Virag Dilip Desai
Virag Dilip Desai

Reputation: 159

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.

Upvotes: 0

Fellmeister
Fellmeister

Reputation: 591

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.

Upvotes: 1

Michael Sync
Michael Sync

Reputation: 4994

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.

Upvotes: 3

X-Cubed
X-Cubed

Reputation: 1899

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

Upvotes: 3

Related Questions