using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.IO; namespace HelloCSharp
{
//[section]
//key=value
//
class IniHelper
{
/// <summary>
/// ini文件的路径
/// </summary>
private string filePath; [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); public IniHelper(string filePath)
{
this.filePath = filePath;
} public void IniWriteValue(string section, string key, string val)
{
WritePrivateProfileString(section, key, val, filePath);
} public string IniReadValue(string section, string key)
{
StringBuilder temp = new StringBuilder();
GetPrivateProfileString(section, key, "", temp, , filePath);
return temp.ToString();
}
}
}

C#访问配置文件的更多相关文章

  1. JAVA访问配置文件总结

    一.全局配置的简单 propertie 文件实现 package com.testgs.utils; import java.util.*; import java.io.*; public fina ...

  2. C#程序中访问配置文件

    在C#编程中,有时候会用到配置文件,那么该如何在程序中获取或修改配置文件中的相关数据呢?下面采用一个简单的C#控制台程序来说明. 新建一个C#控制台程序,打开“解决方案资源管理器”,如下图: 可以看到 ...

  3. Silverlight程序中访问配置文件

    以下代码为本人在一Silverlight程序中访问Web端配置文件的代码: private void GetLoadNeed() { // 项目名称读取配置文件 WebClient wcConfigX ...

  4. 使用java.util.Properties工具制作自定义访问配置文件信息

    import ch.qos.logback.classic.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; im ...

  5. commons configuration管理项目的配置文件

    Commons Confifutation commons configuration可以很方便的访问配置文件和xml文件中的的内容.Commons Configuration 是为了提供对属性文件. ...

  6. 配置文件(App.config文件)

    1. 配置文件概述: 应用程序配置文件是标准的 XML 文件,XML 标记和属性是区分大小写的.它是可以按需要更改的,开发人员可以使用配置文件来更改设置,而不必重编译应用程序.配置文件的根节点是 co ...

  7. asp.net读写配置文件方法

    方法1: System.Collections.Specialized.NameValueCollection nvc = (System.Collections.Specialized.NameVa ...

  8. C# 配置文件读取与修改(转)

    C# 配置文件读取与修改   配置文件在很多情况下都使用到, 配置文件分为两种 一种是应用程序的配置文件, 一种是web的配置文件. 两种配置文件最大的区别是web的配置文件更新之后会实时更新, 应用 ...

  9. C#操作项目配置文件

    前言 对于项目配置文件的读取和修改,.net 提供了ConfigurationManager(位于System.Configuration命名空间) 和WebConfigurationManager( ...

随机推荐

  1. vmware虚拟机挂起后无法再恢复(转)

    之前一直使用vmware调试程序,但有一天它被挂起后,就一直无法恢复. 提示: 无法获取该配置文件上的排他锁 另一个VMware进程可能正在使用此配置文件. 后来在google里查了一下,发现其实是一 ...

  2. J2EE 和javaweb有区别吗

    java web是java对web开发的一种总和称呼.他是B/S模式,对应的是C/S模式: java ee,又叫j2ee是一种广泛使用的平台,包含了一组协调技术,可显著降低成本以及开发.部署和管理以服 ...

  3. oracle 导入数据

    1.在数据库中建立实例数据库之后,运行cmd 2.键入 imp空格(实例数据库名)/(实例数据库口令)空格file=“拖入数据地址” 比如czt.dmp文件直接拖进去(空格)full=y 3.按ent ...

  4. Ext.MessageBox

    Ext.require([ 'Ext.window.MessageBox', 'Ext.tip.*' ]); Ext.onReady(function(){ Ext.MessageBox.confir ...

  5. 05-UIKit绘图演练

    *:first-child { margin-top: 0 !important; } body > *:last-child { margin-bottom: 0 !important; } ...

  6. 点评App wiki-git标准实践

    fetch与pull fetch = pull + merge fetch -p,用于将清理工作同步到本地repository rebase-衍合 merge与rebase是合并的两种方法(上为mer ...

  7. CCF真题Z型输出

    #include<stdio.h> #include<iostream> #include<string.h> #include<algorithm> ...

  8. VC++2005下的ADO SQL语句(like,count,distinct)和操作(转)

    http://blog.sina.com.cn/s/blog_56fd66a70100hxjf.html http://timke.blog.163.com/blog/#m=0 环境:MFC  Dia ...

  9. 手写堆_C++

    一般主程序中拿堆顶元素 x=h[]; h[]=h[top--]; down(); 在堆尾加入元素 h[++top]=x; up(top); 上浮下沉操作 inline void up(int x) { ...

  10. 飞达资讯App总体介绍及关系架构图

    飞达资讯App总体介绍: 下图为飞达资讯App的关系架构图: 该App关系架构图所需的图片云盘链接地址:http://pan.baidu.com/s/1gfHIe4b 提取密码:x1nr 该App的云 ...