We are using a tool that uses internally the simple Win-Api call WritePrivateProfileString
.
I\'m aware of the define flag UNICODE to map either to
Always use WritePrivateProfileStringW
version.
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true,
EntryPoint = "WritePrivateProfileStringW")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool WritePrivateProfileString(string lpAppName, string lpKeyName, string lpString, string lpFileName);
When the INI files does not exist, create it with Unicode file marker (first two bytes FF FE). By this way all strings are stored as Unicode. To create a blank ini file you can use this:
File.WriteAllText(ini_file_path, "; Your comment\r\n", Encoding.Unicode);
A blank/comment line at the beginning is recommended. Write at least "\r\n"
.