I've got this class:
public class CIni
{
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 CIni(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);
// finally return the value found
return temp.ToString();
}
}
Which I use to read out settings from a .ini file. I've also got an auto-updater which I wrote. Everything works fine until the auto-updater attempts to over write the .ini file (with new settings etc). I can't figure out why and the only thing I can think of is that for some reason the dll import keeps the file open?
Seeing as I've not actually got a handle to the file, how would I check to see if it's open/closed? Or does the file get closed automatically after the read/write? In which case, what can I do? Possibly dispose the object?
Thanks in advance!