[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
/// <summary>
/// 写入INI文件
/// </summary>
/// <param name="Section">项目名称(如 [TypeName] )</param>
/// <param name="Key">键</param>
/// <param name="Value">值</param> public void IniWriteValue(string Section, string Key, string Value)
{
WritePrivateProfileString(Section, Key, Value, this.inipath);
}
/// /// <summary>
/// 读出INI文件
/// </summary>
/// <param name="Section">项目名称(如 [TypeName] )</param>
/// <param name="Key">键</param>
public string IniReadValue(string Section, string Key)
{
StringBuilder temp = new StringBuilder(500);
int i = GetPrivateProfileString(Section, Key, "", temp, 500, this.inipath);
return temp.ToString();
} public MainWindow()
{
InitializeComponent(); MessageBox.Show(IniReadValue("App","CanMultiRun"));
// IniWriteValue ("App", "CanMultiRun","1");
MessageBox.Show(IniReadValue("App", "CanMultiRun2")); }
string inipath = System.IO.Path.Combine ( AppDomain.CurrentDomain.BaseDirectory, "AppConfig");

  

C# read write ini file的更多相关文章

  1. Cannot find SS.INI file for user *** 解决方法

    昨天还用的好好的VSS今天早上一来就提示: Cannot find SS.INI file for user *** 度娘了一下,好像都是说的: 1,vss\users\***\  下无文件SS.IN ...

  2. c# ini file

    ini文件主要用于保存配置.之前一直以为是当作普通文本进行操作,读取里面的内容,再自己解析读取的文本.后来发现已经有写好的api函数:WritePrivateProfileString()和GetPr ...

  3. PANIC: HOME is defined but could not find Nexus_4_API_22.ini file in $HOME/.android/avd (Note: avd is searched in the order of $ANDROID_AVD_HOME,$ANDROID_SDK_HOME/.android/avd and $HOME/.android/avd)

    sudo cp /root/.android/avd/*.ini  $Home/.android/avd/ sudo cp -r  /root/.android/avd/*.avd  $Home/.a ...

  4. minIni: A minimal INI file parser

    https://www.compuphase.com/minini.htm https://github.com/compuphase/minIni

  5. [PowerShell]get data from Ini File

    $filedata = @' app.name=Test App app.version=1.2 '@ $filedata | set-content appdata.txt $AppProps = ...

  6. Unity Download Assistant Error: 'SendRequest Error' while downloading ini file from http://files.unity3d.com/bootstrapper/29055738eb78/unity-5.3.6f1-win.ini

    Unity 官网的哥们如此说道 I open the exe on Compatibility Mode , it's solved. You can try. :) 翻译就是 我用兼容模式打开,就能 ...

  7. PANIC: ANDROID_SDK_HOME is defined but could not find Nexus_5_API_23.ini file in $ANDROID_SDK_HOME\

    运行模拟器总是出现这个错误 后来把系统环境变量中的ANDROID_SDK_HOME 删掉就好了 我去,好神奇的操作

  8. 修改PHP 加载loaded configuration file 目录

    在/usr/local/php/etc/目录下新建php2.ini 复制php.ini 内容到php2.ini 或cp php.ini 也行. 配置php-fpm 参数: Usage: php [-n ...

  9. C# 读本地INI文件方法

    [DllImport("kernel32")]//加载dll private static extern int GetPrivateProfileString(string se ...

随机推荐

  1. webpack4.x初使用

    1.nodejs环境,建议下载v8.2以上版本的,低版本怕是有些api已经废弃,链接附上(https://npm.taobao.org/mirrors/node/) 2.网上一些教程有的是webpac ...

  2. Maven学习(四)eclipse创建maven项目

    eclipse创建Maven web项目 1.创建新项目 选择File -> New ->Project 选择New Project窗口中选择 Maven -> Maven Proj ...

  3. flutter 异步async、await和Future的使用技巧

    由于前面的HTTP请求用到了异步操作,不少小伙伴都被这个问题折了下腰,今天总结分享下实战成果.Dart是一个单线程的语言,遇到有延迟的运算(比如IO操作.延时执行)时,线程中按顺序执行的运算就会阻塞, ...

  4. 完美实现Android的屏幕常亮功能

    笔者所在公司做的APP是股票类的,用户在查看股票报价页面的时候,往往需要开启盯盘模式,这个时候屏幕是不能黑屏的,黑屏会导致用户看不到一些关键报价涨跌,错过了买入卖出的最佳时机,就会给用户造成损失,这是 ...

  5. pt-heartbeat --update --daemonize 只执行一次秒退的问题

    使用pt-heartbeat帮助测试MySQL从库delay时长- 第一次运行测试成功,运行顺畅. 过几天再次用--update测试时,发现pt-heartbeat只update一次就自己退出了,-- ...

  6. django —— 邮件

    官方文档 1.11 配置settings.py # QQ邮箱为例, 其他邮箱对应的SMTP配置可查官方 EMAIL_HOST = "smtp.qq.com" EMAIL_PORT ...

  7. 使用Vagrant和VirtualBox一步步地创建一个Base Box

    box集合  http://www.vagrantbox.es/ Vagrant和VirtualBox软件的安装步骤省略,去官网下载最新的版本然后下一步下一步地安装就行了,和正常的安装软件没有什么区别 ...

  8. JDK5 新特性之 可变参数的方法(2)---asList

    > Arrays.asList(T - a)方法的使用 >UnsupportedOperationException分析     Arrays.asList(T - a)方法的使用 pac ...

  9. gnome美化

    调整工具更新可以移动窗口控件gnome-tweak-tool # dnf install gnome-tweak-tool 命令行启动,并且要在普通用户下启动 $ gnome-tweak-tool 在 ...

  10. Angular2学习笔记(1)——Hello World

    1. 写在前面 之前基于Electron写过一个Markdown编辑器.就其功能而言,主要功能已经实现,一些小的不影响使用的功能由于时间关系还没有完成:但就代码而言,之前主要使用的是jQuery,由于 ...