Well that i looking for is, how to create a file to store applicaiton settings, i prefer ini files...
well i found smthing, it work ok, but i cant understand how it work.
What his code do? well this code store informations in *.ini
file,
example
[SECTION]
Option1 = Nab
Option2 = Idiot
[SECTION 2]
ImPRO = False
........... // And More...
This my code...
using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
namespace clsINI
{
public static class config
{
public static string path = System.Windows.Forms.Application.StartupPath + @"\Result.ini";
public static IniFile ini = new IniFile(path);
public static string getKeyValue(string section, string key)
{
string tmp = String.Empty;
tmp = ini.IniReadValue(section, key);
return tmp;
}
}
public class IniFile
{
public string path;
[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(string INIPath)
{
path = INIPath;
}
public void IniWriteValue(string Section, string Key, string Value)
{
WritePrivateProfileString(Section, Key, Value, this.path);
}
public string IniReadValue(string Section, string Key)
{
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Section, Key, "", temp, 255, this.path);
return temp.ToString();
}
}
}
How it work lol? i dont see smthink like..
private void WriteToFIle(string section, string key)
{
StreamWrite sw = new StreamWriter("config.ini");
sw.AppendText(section, key);
}
well im just new in programming, but the code i found is just an "empety" code, how do that? maby there is a funcion in dll file?
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
?? i hope you understand me :)