Silverlight 4.0:如何增加独立文件存储的配额

发布于 2024-08-24 22:49:21 字数 853 浏览 13 评论 0原文

得到这行代码 此处 但它不起作用。

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

我的奇迹 2024-08-31 22:49:21

我建议你删除所有断点并运行它。我只是复制您提到的文章中的代码,它工作正常。

还有一件事。如果它不起作用,那么尝试使用 IE..

如您所知,此代码 isf.IncreaseQuotaTo(newSpace) 应该位于用户启动的事件中。将向用户显示一个对话框,并且用户需要同意增加空间。

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.

坏尐絯℡ 2024-08-31 22:49:21

增加配额的请求需要来自用户发起的事件,例如按键或按钮单击。

请参阅备注部分: http://msdn.microsoft.com/en-us/library/system.io.isolatedstorage.isolatedstoragefile.increasequotato(VS.95).aspx

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

一口甜 2024-08-31 22:49:21

使用断点将使 Silverlight 需要的用户启动操作无效,以增加存储配额,并且在调用时不会增加大小。按照建议删除断点,看看是否可以解决您的问题。

不过,使用 Debug.Writeline 应该不会引起问题。我用它们测试了我的工作代码,它运行得很好。

我的代码是从这里提取的:http://msdn。 microsoft.com/en-us/library/cc265154(VS.95).aspx

我选取的部分是IncreaseQuota_OnClick 并从我的按钮引用了该部分。

里面还有一些其他的好方法。

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.

挽梦忆笙歌 2024-08-31 22:49:21

确保在执行代码之前删除所有断点。我犯了同样的错误,当我删除断点后,一切就正常了,我成功地增加了isolatedStorage的大小。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文