You do not need to create/read/write anything! All you need to do is use the class, the ini file will create itself, update itself, and read itself on command.PHP Code:
using System;
using System.Text;
using System.Runtime.InteropServices;
class INIFile
{
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(String Section, String Key, String Value, String FilePath);
[DllImport("kernel32")]
private static extern Int32 GetPrivateProfileString(String Section, String Key, String Definition, StringBuilder Return, Int32 Size, String FilePath);
private String FilePath = String.Empty;
public INIFile(String FilePath)
{
this.FilePath = FilePath;
}
public String this[String Key]
{
get
{
return this["Default", Key];
}
set
{
this["Default", Key] = value;
}
}
public String this [String Section, String Key]
{
get
{
StringBuilder Temp = new StringBuilder(255);
GetPrivateProfileString(Section, Key, "", Temp, 255, this.FilePath);
return Temp.ToString();
}
set
{
WritePrivateProfileString(Section, Key, value, this.FilePath);
}
}
}
Allows you to create and use ini setting files for configuration.
Example Usage;
That will automatically create the ini, and update the ini data, readable at next program entrance.PHP Code:
INIFile Temp = new INIFile("C:\\Test.ini");
Temp["width"] = 10;
Results 1 to 1 of 1
Thread: [Release - C#] INIFile Class
- 28 Dec. 2010 04:01am #1
- Age
- 30
- Join Date
- Nov. 2009
- Location
- Anaheim, California
- Posts
- 1,065
- Reputation
- 99
- LCash
- 62.87
[Release - C#] INIFile Class