Q:

C# WritePrivateProfileString() value other than English language

I am trying to save a file path in ini file which contains a folder in Arabic language. i.e.

D:\ملف جديد\Checking Folder

But after using WritePrivateProfileString() to write it in settings.ini . It shows path as follows:

D:\??? ????\Checking Folder

What should I do to save the path correctly?
Edit:
Following is the code I am using to write ini file
[DllImport("kernel32")]

private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);

A:

You have to use System.Text.Encoding.GetEncoding("Arabic") for using Arabic Text in the path
Like for example if you want to read and write in the file than
using (var reader = new System.IO.StreamReader("YourFilePath", System.Text.Encoding.GetEncoding("Arabic")))
{
}

using (var writer = new System.IO.StreamWriter("YourFilePath", true, System.Text.Encoding.GetEncoding("Arabic")))
{
}

A:

You could try out my INI library, I created it in order to have a friendlier (and more meaningful / intuitive) API then those WritePrivateProfile APIs.
Here is a sample of how you can use it:
// Your inputs.
string section, key, val, filePath;

var iniOptions = new IniOptions();
iniOptions.Encoding = Encoding.UTF8;

var ini = new IniFile(iniOptions);
ini.Load(filePath);

IniSection iniSection = ini.Sections[section];
IniKey iniKey = iniSection.Keys[key];
iniKey.Value = val;

ini.Save(filePath);

I hope this helps.

