读取Config.ini文件内容
来源:互联网 发布:数据库表字段设计原则 编辑:程序博客网 时间:2024/05/17 11:57
Config.ini文件内容:
[database]
servername =localhost
database = shenxun
uid = sa
pwd =
servername =localhost
database = shenxun
uid = sa
pwd =
using System;
using System.Text;
using System.Runtime.InteropServices;
namespace TEst2
{
///<summary>
/// ReadConfig 的摘要说明。
///</summary>
public class ReadConfig
{
public static string FileName = "Config.ini";
public ReadConfig()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
[DllImport("kernel32.dll")]
private static extern int GetPrivateProfileString(string section,
string key,string def,StringBuilder retVal,int size,string filePath);
public static string ReadIniValue(string Section,string Key,string ThisPath )
{
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Section,Key,"",temp,255, ThisPath + "//" + FileName);
return temp.ToString();
}
public void ReadFile( ref string ServerName,ref string DataBase,ref string UID,ref string PWD,string ThisPath)
{
try
{
ServerName=ReadIniValue ("database","servername",ThisPath);
DataBase = ReadIniValue( "database","database",ThisPath);
UID = ReadIniValue( "database","uid",ThisPath);
PWD = ReadIniValue( "database","pwd",ThisPath);
}
catch( Exception err )
{
throw new Exception( err.Message );
}
finally
{
}
}
public bool CheckFile()
{
if ( !System.IO.File.Exists( FileName ) )
{
return false;
}
else
return true;
}
}
}
- 读取Config.ini文件内容
- vfp读取config.ini文件
- java读取config.ini
- 读取INI配置文件内容(头文件head)
- 通过C#读取ini文件中的内容
- sharepoint timer job 读取config文件内容
- 读取App.config文件中的内容
- FileUpload上传文件及读取 .ini 文件内容
- 读取.ini文件里面的连接数据库的代码、读取App.config文件的代码
- VC读取写入 ini文件内容的方法函数详解
- API读取写入 ini文件内容的方法函数详解
- VC读取写入 ini文件内容的方法函数详解
- API读取写入 ini文件内容的方法函数详解
- C++读取INI文件内容存放Map中
- C# 读写 config.ini 文件
- Python 处理config.ini文件
- Ini文件读取类
- 读取Ini文件
- 如果你不买windows vista,我们将.......
- 在Thinkpad上安装Ubuntu笔记
- VoIP基础知识
- java程序获得windows系统的一些参数(cmd指令运行返回结果)
- 一个统计直方图的函数
- 读取Config.ini文件内容
- 一个统计用的饼状图的函数
- 百家姓
- About FYI
- 为数据库建立索引(一)
- 使用xp_Regwrite夺取radmin
- rmi
- 建立空连接的代码
- 为数据库建立索引(二)