I save a parameter (a Persian text
) manually to .ini
File. Now I want to read it in C# (WPF)
using this Code:
[DllImport("kernel32", CharSet = CharSet.Unicode)]
public static extern int GetPrivateProfileString(
string Section,
string Key,
string Default,
StringBuilder RetVal,
int Size,
string FilePath);
When I want to show it using MessageBox, I get some un-known characters
. Even I tried this code for encoding (with different type of encoding):
var enc = Encoding.Default;
var bytes = enc.GetBytes(_address);
System.Windows.MessageBox.Show(
_address);
but I still see, unknown character. _address
is aforementioned Persian parameter, which as retrieved using GetPrivateProfileString
method (as retVale). I note that I can see the string is saved normally (in NotePad with UTF-8). How can I fix this problem?