Silverlight 4.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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我建议你删除所有断点并运行它。我只是复制您提到的文章中的代码,它工作正常。
还有一件事。如果它不起作用,那么尝试使用 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.
增加配额的请求需要来自用户发起的事件,例如按键或按钮单击。
请参阅备注部分: 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
使用断点将使 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.
确保在执行代码之前删除所有断点。我犯了同样的错误,当我删除断点后,一切就正常了,我成功地增加了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.