Silverlight不会提示增加配额

时间:2010-04-10 21:02:57

标签: silverlight localhost isolatedstorage quota

我正在尝试使用Silverlight的隔离存储功能。 目前通过ASP.NET页面运行Silverlight。

我已经编写了一些代码来请求额外的存储空间,但我没有被提示添加更多内容。

private void requestButton_Click(object sender, RoutedEventArgs e)
{
    using (IsolatedStorageFile store = 
        IsolatedStorageFile.GetUserStoreForApplication())
    {
        if (store.AvailableFreeSpace >= 1000*1024) return;

        long usedSpace = store.Quota - store.AvailableFreeSpace;
        if (store.IncreaseQuotaTo(usedSpace + 1000*1024))
            statusTextBlock.Text = 
                string.Format("Quota has been increased to {0}", store.Quota);
        else
            statusTextBlock.Text = 
                "You have denied quota increase... you Inglorious Basterd...";
    }
}

Silverlight的Application Storage选项卡会列出托管Silverlight的localhost ASP.NET页面,如下所示。

alt text

根据截图,http://localhost:54389有1.0MB的可用存储空间 localhost网站是否设置了限制提示被忽略的内容?

Silverlight提示用户增加配额的必要步骤是什么?

1 个答案:

答案 0 :(得分:1)

也许这看起来有点简单,但是你的屏幕截图显示localhost:54389使用的当前空间是0.0MB。因此AvailableFreeSpace将是1.0 MB(当前配额的大小)。现在你的代码中有这一行: -

 if (store.AvailableFreeSpace >= 1000*1024) return;

在此基础上,我希望您的代码在此时返回。