开发者

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 n开发者_StackOverflowewSpace = isf.Quota + 1523456786435;
            try
            {
                if (true == isf.IncreaseQuotaTo(newSpace))
                {
                    Debug.WriteLine("success");
                }
                else
                {
                    Debug.WriteLine("unsuccessful");
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
    }


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.


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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜