For example, I spent the last 30 minutes customizing a customer made C# .NET class that should of been part of .NET framework. After some googling, I have found the following:
http://www.codeproject.com/KB/cs/cs_ini.aspx
It fit my needs, almost. So I ended up modifying it to make it a bit more full proof and integrated ;) ... at least for C# 2008.
Below is the code ...
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() { throw new System.ArgumentException("Parameter cannot be null.", "IniFile"); } public IniFile(string INIPath) { path = INIPath; } public void SetFile(string INIPath) { path = INIPath; } public void WriteValue(string Section, string Key, string Value) { WritePrivateProfileString(Section, Key, Value, this.path); } private string ReadValue(string Section, string Key) { StringBuilder temp = new StringBuilder(255); int i = GetPrivateProfileString(Section, Key, "", temp, 255, this.path); return temp.ToString(); } private string ReadValue(string Section, string Key, string Def) { string sTemp = ReadValue(Section, Key); if (sTemp == string.Empty) sTemp = Def; return sTemp; } public string ReadString(string Section, string Key) { return ReadValue(Section, Key); } public string ReadString(string Section, string Key, string Def) { return ReadValue(Section, Key, Def); } public int ReadInt(string Section, string Key) { int ret; string r = ReadValue(Section, Key, "0"); int.TryParse(r, out ret); return ret; } public int ReadInt(string Section, string Key, int Def) { int ret; string r = ReadValue(Section, Key, Def.ToString()); int.TryParse(r, out ret); return ret; } }
I am sure there may be other, better ways of doing the above and support all primary data types .net supports. But the above supports my needs nicely.
Sometimes it makes me thankful that the Pure Basic author have at least partially implemented such functionality. That still doesn't make up for lack of support.