using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Data;
using System.Configuration;
using System.Collections;
public class IniFile
{
[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 IniFile()
{
}
// Write ini file
public void IniWriteValue(string Section, string Key, string Value, string inipath)
{
WritePrivateProfileString(Section, Key, Value, inipath);
}
// Read ini file
public string IniReadValue(string Section, string Key, string inipath)
{
int buffer;
buffer = 255; // Define length
StringBuilder temp = new StringBuilder(buffer);
GetPrivateProfileString(Section, Key, "", temp, buffer, inipath);
return temp.ToString();
}
}