本文介绍了如何使用独立存储在WP 8.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何使用 IsolatedStorage 在此代码:

private void Button_Click(object sender, RoutedEventArgs e)
    {
            textblock.Visibility = Visibility.Visible;

    }



我使用的Windows Phone 8.1的Silverlight C#

I use Windows Phone 8.1 Silverlight c#

推荐答案

尝试使用这个类实现

     public class LocalSetting
{


   public LocalSetting()
   {

   }

   public void Write(string key,string value)
   {
       try
       {
           var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
           localSettings.Values[key] = value;
       }
       catch(Exception)
       {
           MessageDialog msgbox = new MessageDialog("Erreur d'ecriture");
           msgbox.ShowAsync();
           return;

       }


   }

   public String Read(string key)
   {
       try
       {
       var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
       if(localSettings.Values.Keys.Contains(key))

      return localSettings.Values[key].ToString();
       else 
      return "";



         }
       catch(Exception)
       {
           MessageDialog msgbox = new MessageDialog("Erreur de lecture");
           msgbox.ShowAsync();
           return "";

       }
   }



}

这篇关于如何使用独立存储在WP 8.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 00:44