如何更改IsolatedStorage默认存储限额

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

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

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

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

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

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

  
  
  
  
  1. using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) 
  2.     try 
  3.     { 
  4.         if (true == isf.IncreaseQuotaTo(1048576 * 2))//将限额增加到2MB(注: 这里单位是bytes)  
  5.         { 
  6.             Results.Text = "限额更改成功."
  7.         } 
  8.         else 
  9.         { 
  10.             Results.Text = "限额更改失败."
  11.         } 
  12.     } 
  13.     catch (Exception e) 
  14.     { 
  15.         System.Windows.Browser.HtmlPage.Window.Alert(e.Message); 
  16.     } 

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

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

Source code: IsolatedStorageDEMO2

你可能感兴趣的:(silverlight)