如何更改IsolatedStorage默认存储限额

上次我们说到可以更改IsolatedStorage的默认存储限额,接下来我给大家介绍一下如何查看现在我们对IsolatedStorage的使用状况

首先打开我们Silverlight配置页面(Silverlight Configuration):

选择应用程序存储(Application Storage)选项卡:

这下当前存储状态一目了然了吧~ 当然我也可以在程序中获取这些属性.

            using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
            
{
                isf.AvailableFreeSpace.ToString() 
+ " bytes";//这里是剩余空间
                isf.Quota.ToString() + " bytes";//这里是当前的限额
                (isf.Quota - isf.AvailableFreeSpace).ToString() + " bytes";//这里是用户已经使用的空间
              }

好的 现在我们来看看如何更改默认限额吧~

 

            using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
            
{
                
try
                
{
                    
if (true == isf.IncreaseQuotaTo(1048576 * 2))//将限额增加到2MB(注: 这里单位是bytes) 
                    {
                        Results.Text 
= "限额更改成功.";
                    }

                    
else
                    
{
                        Results.Text 
= "限额更改失败.";
                    }

                }

                
catch (Exception e)
                
{
                    System.Windows.Browser.HtmlPage.Window.Alert(e.Message);
                }

            }

很简单吧~ 这里有的朋友要可能要问 上次存储我们那些数据放在哪啦

就此告送大家应该在C:\Users\sonic\AppData\LocalLow\Microsoft\Silverlight\is\gsp5lhdk.hho\ulgnbrmt.oex\1\s\1q1n5d1w2fxymchxxzodpthfoihskwnyxxqcmkokboh55qcc3naaacga\f\sonic.txt

 

Source code: IsolatedStorageDEMO2

posted @ 2008-07-19 15:31  王博_Nick  Views(730)  Comments(1Edit  收藏  举报