有没有办法减少Silverlight中的IsolatedStorage容量?
使用此代码,我可以让 Silverlight 询问用户是否要增加isolatedStorage:
private void Button_IncreaseIsolatedStorage_Click(object sender, RoutedEventArgs e)
{
IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication();
long newStorageCapacityInBytes = FileHelpers.GetMaxiumumSpace() + SystemHelpers.GetAmountOfStorageToIncreaseWhenNeededInBytes();
store.IncreaseQuotaTo(newStorageCapacityInBytes);
Message = "IsolatedStorage increased. " + FileHelpers.GetSpaceLeftMessage();
}
但如果我尝试将其设置为小于当前的数量,则会收到一条错误消息,表明这是不可能的。
是否有解决方法,即我可以减少IsolatedStorage的数量吗?这至少对于测试目的很有用。
相关问题:当用户同意增加IsolatedStorage时,其他应用程序可以使用此容量还是只能使用他增加的应用程序?我认为这就是存在上述限制的原因。< /p>
With this code I can have Silverlight ask the user if he wants to increase IsolatedStorage:
private void Button_IncreaseIsolatedStorage_Click(object sender, RoutedEventArgs e)
{
IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication();
long newStorageCapacityInBytes = FileHelpers.GetMaxiumumSpace() + SystemHelpers.GetAmountOfStorageToIncreaseWhenNeededInBytes();
store.IncreaseQuotaTo(newStorageCapacityInBytes);
Message = "IsolatedStorage increased. " + FileHelpers.GetSpaceLeftMessage();
}
But if I try to set it to an amount less than it current is, I get an error that this is not possible.
Is there a workaround for this, i.e. can I reduce the amount of IsolatedStorage? This would be useful for testing purposes at least.
Related question: When the user agrees to increasing IsolatedStorage, can other applications use this capacity or just the application in which he increased it? I assume this is the reason the above limitation is there.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于增加是在隔离存储文件上执行的,因此只有您的应用程序(或您域中托管的其他应用程序)可以使用新配额:
另外,似乎一旦增加,就无法返回(以编程方式):
http://msdn.microsoft.com/en-us/library/system.io.isolatedstorage.isolatedstoragefile.increasequotato%28v=VS.95%29.aspx
Since the Increase is performed on an IsolatedStorage File, only your application (or others hosted in your domain) can use the new quota:
Also, it seems that once you increase, you cannot go back (programmatically):
http://msdn.microsoft.com/en-us/library/system.io.isolatedstorage.isolatedstoragefile.increasequotato%28v=VS.95%29.aspx
一旦分配了IsolatedStorage,减少IsolatedStorage 的唯一方法是使用Silverlight 配置对话框删除站点IsolatedStorage。您无法以编程方式执行此操作,用户必须打开配置对话框并故意选择删除站点存储。
配额是分配给站点的,因此,当一个应用程序请求增加配额时,站点中的其他应用程序可能会从该配额中分配空间。
The only way to reduce IsolatedStorage once allocated is to delete a sites IsolatedStorage using the Silverlight Configuration dialog. You can't do this programmatically the user has to open the configuration dialog and deliberately choose to delete the sites storage.
The quota is allocated to the site so yes when one application requests the quota to be increased other applications in the site may allocate space from that quota.