Isolated storage 独立存储

一个程序不能操作其他程序的独立存储 和不能操作文件系统,独立存储是虚拟的文件系统。

System.IO.IsolatedStorage.

IsolatedStorageSettings +++IsolatedStorageFile 两个主要类

IsolatedStorageSettings 使用 key +value 键值对的形式存储数据 常用方法  Add, Remove, and Contains.

IsolatedStorageFile 使用文件和目录 存数据  常用方法FileExists, CreateFile,OpenFile, and DeleteFile., DirectoryExists, CreateDirectory, DeleteDirectory

vs 中可以使用命令行 启动ISETool 来查看 ,独立存储的数据 ,调用方式

C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.1\Tools\IsolatedStorageExplorerTool\ISETool.exe

image

  public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        IsolatedStorageSettings mySettings;
        public MainPage()
        {
            InitializeComponent();
            mySettings = IsolatedStorageSettings.ApplicationSettings;
        }

private void btnSaveSettings_Click(object sender,RoutedEventArgs e)
{
  if (!String.IsNullOrEmpty(tbNameContent.Text))
{

if (mySettings.Contains("setName"))
{
mySettings["setName"] = tbNameContent.Text;
}
else
mySettings.Add("setName", tbNameContent.Text);
mySettings.Save();
}
}

}

posted on 2012-05-31 16:07  GIS-MAN  阅读(286)  评论(0编辑  收藏  举报

导航