Hi.My program VCL in OnClose event should take these steps:1. If the Desktop is not created then create a folder named MyFiles.2. Load a file to the TMemoryStream.3. Save this file to Desktop in the MyFiles folder with the encoding UTF-8. If the file exists, then overwrite it. The file has an extension .iniI can not find С++ examples with Desktop anywhere. I only know the second step:

Thank you very much!I have two questions:1. Do I need to delete the file from the folder MyFiles before I copy it there? Is it best way? I need to overwrite the file.2. I use the received file in the Android project. How to get it after copying encoded UTF-8?

If this parameter is TRUE and the new file specified by lpNewFileName already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds.

Lena wrote:I need to overwrite the file.

Then set the bFailIfExist parameter of CopyFile() to FALSE.

Lena wrote:I use the received file in the Android project. How to get it after copying encoded UTF-8?

My program has two versions. One for Windows is the second for Android. In Windows versions I work with a file ini encoded ANSI. After closing my Windows program, I want to get a duplicate of this file but in the encoding UTF-8. I need two files ini (ANSI and UTF-8).ANSI version ini I use in my Windows program.UTF-8 version ini user use in my Android program. User manual copied this ini UTF-8 file in Android device.

Lena wrote:In Windows versions I work with a file ini encoded ANSI. After closing my Windows program, I want to get a duplicate of this file but in the encoding UTF-8. I need two files ini (ANSI and UTF-8).

Then you need to open the first file, read it using ANSI and convert it to Unicode, and then save the Unicode to the second file using UTF-8. You can do that easily with TMemIniFile, eg:

That doesn't answer my question. If you are using a Unicode UI (which you should be), then you should be using an UTF-8 file, not an ANSI file. Unless you are dealing with legacy data (which you should convert to Unicode), there is no good reason to use ANSI anymore.

That doesn't answer my question. If you are using a Unicode UI (which you should be), then you should be using an UTF-8 file, not an ANSI file. Unless you are dealing with legacy data (which you should convert to Unicode), there is no good reason to use ANSI anymore.

Sorry, I do not fully understand.I create VCL project in C++ Builder Berlin.I create ini files in notepad and save in notepad UTF-8.INI:

On Windows, TIniFile wraps the Win32 PrivateProfile API. On most Windows versions (at least up to Windows 7 - I didn't test Windows 8+), the Unicode version of the PrivateProfile functions do not support UTF-8 files, only UTF-16 files. So ReadSections() returns an empty TStringList, and ReadString() returns the specified default string. If you save your INI file as UTF-16 instead of UTF-8, then TIniFile works correctly.

TMemIniFile does not have that limitation. It can load and save UTF-8 files just fine, as long as you use TEncoding::UTF8. And TIniFile is an alias for TMemIniFile on non-Windows platforms.