zoukankan      html  css  js  c++  java
  • WP7应用开发笔记(7) 配置和存储

    配置

    既然选择了TCP协议,那么从WP7手机连接到TCP服务器,必须要知道服务器的IP和端口。为了方便服务器端口使用固定的8012端口。

    那么WP7至少需要在手机上存储IP地址字符串。

    Windows Phone 本地数据存储

    Windows Phone 应用程序可以使用独立存储将数据储存到手机本地。应用程序可以通过三种方式储存数据:

    1. 设置:使用 IsolatedStorageSettings 类将数据存储为键/值对。
    2. 文件和文件夹:使用 IsolatedStorageFile 类存储文件和文件夹。
    3. 本地数据库:7.1新增,只能支持LINQ TO SQL ,不能写SQL语句。

    本地存储IP数据

    因为我只需要存储一个IP地址,不用考虑,IsolatedStorageSettings是最佳选择。下面是一个包装封装类,看看IsolatedStorageSettings是如何使用的吧。

     public static class IPEndPointStorage
      {
            private const string Key = "ipaddress";
            public const int Port = 8012;
    
            public static string IPAddress
            {
                get
                {
                    string ipAddress;
                    return IsolatedStorageSettings.ApplicationSettings.TryGetValue(Key, out ipAddress) ? ipAddress : null;
                }
                set { IsolatedStorageSettings.ApplicationSettings[Key] = value; }
            }
    }
  • 相关阅读:
    在Android中如何获取视频的第一帧图片并显示在一个ImageView中
    利用MsChart控件绘制多曲线图表 z
    国外成熟的程序交易系统的思路 z
    稳健获利
    用vmware安装gho文件
    数学之美 zt
    大型邮箱smtp服务器及端口 收集
    英语之路 zt
    C# Get Desktop Screenshot ZZ
    C#/PHP Compatible Encryption (AES256) ZZ
  • 原文地址:https://www.cnblogs.com/kiminozo/p/2329567.html
Copyright © 2011-2022 走看看