zoukankan      html  css  js  c++  java
  • C# 读写 Ini 文件

    using System.Runtime.InteropServices;
    public class IniFile
    {
        
    private string path;

        
    public IniFile(string iniPath)
        {
            
    this.path = iniPath;
        }

        [DllImport(
    "kernel32")]
        
    private static extern int GetPrivateProfileString
            (
    string section, string key, string def, StringBuilder retVal, int size, string filePath);
        [DllImport(
    "kernel32")]
        
    private static extern long WritePrivateProfileString
            (
    string section, string key, string val, string filePath);

        
    public string IniReadValue(string section, string key)
        {
            
    try
            {
                StringBuilder retVal 
    = new StringBuilder(0xff);
                
    if (GetPrivateProfileString(section, key, "", retVal, 0xffthis.path) == 0)
                {
                    
    return string.Empty;
                }
                
    return retVal.ToString();
            }
            
    catch (Exception exception)
            {
                
    return exception.ToString();
            }
        }

        
    public void IniWriteValue(string Section, string Key, string Value)
        {
            WritePrivateProfileString(Section, Key, Value, 
    this.path);
        }
    }
  • 相关阅读:
    CMMI全称是Capability Maturity Model Integration,即能力成熟度模型集成
    【beta】Scrum站立会议第5次....11.7
    【beta】Scrum站立会议第3次....11.6
    补交进度条
    【beta】Scrum站立会议第1次....11.3
    【week7】psp
    【week6】psp
    【week6】约跑App视频链接
    【week6】团队贡献分
    【week6】用户数
  • 原文地址:https://www.cnblogs.com/anjou/p/1584715.html
Copyright © 2011-2022 走看看