私はこのクラスを持っています:
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();
}
}
.ini ファイルから設定を読み取るために使用します。私が書いた自動アップデーターもあります。自動アップデーターが .ini ファイルを (新しい設定などで) 上書きしようとするまで、すべて正常に動作します。理由がわかりません。考えられる唯一のことは、何らかの理由でdllインポートがファイルを開いたままにしているということですか?
実際にファイルへのハンドルを取得していないので、ファイルが開いているか閉じているかを確認するにはどうすればよいですか? または、読み取り/書き込み後にファイルが自動的に閉じられますか? その場合、どうすればよいですか?おそらくオブジェクトを破棄しますか?
前もって感謝します!