有没有办法减少Silverlight中的IsolatedStorage容量?

发布于 2024-08-28 17:04:44 字数 780 浏览 4 评论 0原文

使用此代码,我可以让 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();
}

但如果我尝试将其设置为小于当前的数量,则会收到一条错误消息,表明这是不可能的。

  1. 是否有解决方法,即我可以减少IsolatedStorage的数量吗?这至少对于测试目的很有用。

  2. 相关问题:当用户同意增加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.

  1. Is there a workaround for this, i.e. can I reduce the amount of IsolatedStorage? This would be useful for testing purposes at least.

  2. 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 技术交流群。

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

发布评论

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

评论(2

如若梦似彩虹 2024-09-04 17:04:44

由于增加是在隔离存储文件上执行的,因此只有您的应用程序(或您域中托管的其他应用程序)可以使用新配额:

由于隔离存储的范围仅限于特定程序集,因此大多数其他托管代码将无法访问您的代码数据(高度可信的托管代码和管理工具可以访问来自其他程序集的存储)。非托管代码可以访问任何隔离存储。

另外,似乎一旦增加,就无法返回(以编程方式):

应用程序与同一域(网站)上托管的所有其他应用程序共享其配额。初始配额为 1 MB,由所有域的应用程序共享。
新的配额大小不得小于当前配额。 仅允许增加配额。

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:

Since isolated stores are scoped to particular assemblies, most other managed code will not be able to access your code's data (highly trusted managed code and administration tools can access stores from other assemblies). Unmanaged code can access any isolated stores.

Also, it seems that once you increase, you cannot go back (programmatically):

An application shares its quota with all other applications that are hosted on the same domain (Web site). The initial quota is 1 MB to be shared by all of the domain's applications.
The new quota size must not be less than the current quota. Only quota increases are allowed.

http://msdn.microsoft.com/en-us/library/system.io.isolatedstorage.isolatedstoragefile.increasequotato%28v=VS.95%29.aspx

神也荒唐 2024-09-04 17:04:44

一旦分配了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.

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