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)上测试通过


     

  • 相关阅读:
    apollo-springboot 整合使用
    axon 过滤存储哪些事件
    springtools 解决lombok
    mylog 自定义注解打印 logger
    java高级应用:线程池全面解析
    监控 Java 线程池运行状态
    线程池获当前使用的活跃线程数
    JVM调优总结 -Xms -Xmx -Xmn -Xss(1)
    java高并发之线程池
    Nginx 网络事件
  • 原文地址:https://www.cnblogs.com/greatandforever/p/1595794.html
Copyright © 2011-2022 走看看