zoukankan      html  css  js  c++  java
  • Windows Mobile 读写配置文件

    读写INI:

     首先,得到当前exe的运行路径  
      ApplicationPath   =   Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);  
      下面是操作INI文件的类  

    using System;
    using System.Runtime.InteropServices;
    using System.Text;
    using System.IO;

    namespace Ini
    {
        
    ///   <summary>   
        
    ///   Ini的摘要说明。   
        
    ///   </summary>   

        public class IniFile
        
    {

            
    public string path;

           
    写入信息文件

            
    读取信息文件

            
    public IniFile(string INIPath)
            
    {
                path 
    = INIPath;
            }


            
    public void IniWriteValue(string Section, string Key, string Value)
            
    {
                WritePrivateProfileString(Section, Key, Value, 
    this.path);
            }


            
    public string IniReadValue(string Section, string Key)
            
    {
                
    return GetPrivateProfileString(Section, Key, ""this.path);
            }


        }

    }

    使用方法  
      写信息文件  
      IniFile   NewIni   =   new   IniFile(ApplicationPath   +   "\\Test.ini");  
      NewIni.IniWriteValue("测试信息","测试一","1");  
       
      读取  
      IniFile   NewIni   =   new   IniFile(ApplicationPath   +   "\\Test.ini");  
      string   a   =   NewIni   .IniReadValue("测试信息","测试一");  
       
      读取结果  
      a   =   1

     备注:以上代码在HP   2490(WM5)上测试通过


     

  • 相关阅读:
    动态网络社团检测学习笔记 --- 随机块模型小结之简介
    十五组第四次作业
    17现代软件工程十五组第二次作业
    17现代软件工程十五组第三次作业
    现代软件工程2017十五组成员介绍
    软件测试学习日志3 ————软件测试作业之控制流图
    软件测试学习日志———— round 2 Junit+intellj idea 安装及简单的测试使用
    软件测试学习日志————round 1 some questions of two small programs
    [关于printPrime是()方法的控制流图和点覆盖、边覆盖、主路径覆盖]
    【在myeclipse中使用Junit(4.12), Hamcrest(1.3) 和Eclemma】
  • 原文地址:https://www.cnblogs.com/greatandforever/p/1595794.html
Copyright © 2011-2022 走看看