Question about the component SHFILEOPSTRUCT. More precisely about his work with the Russian text. The task is to copy files from one folder to another. Thanks for the help!

String slSourceDir1= "C:\\ПапкаИзКоторйБудутКопироватьсяФайлы\\*.*"; String slTargetDir1 = "C:\\ПапкаВКоторуюБудутКопироватьсяФайлы"; SHFILEOPSTRUCT SHF ; SHF.hwnd = 0; SHF.pFrom = slSourceDir1.c_str(); SHF.pTo = slTargetDir1.c_str(); SHF.fFlags = FOF_ALLOWUNDO; SHF.wFunc = FO_COPY; String Text = "Резервное копирование файлов 1С."; SHF.fFlags = SHF.fFlags | FOF_SIMPLEPROGRESS; SHF.lpszProgressTitle = Text.c_str(); if( SHFileOperation(&SHF) != 0) if (SHF.fAnyOperationsAborted) ShowMessage( "Выполнение операции прервано пользователем"); else ShowMessage("Ошибка выполнения операции"); else ShowMessage("Операция успешно завершена"); 

It turns out that. The receiving folder can be with the Russian text, but the folder from which the files are taken, categorically swears. If the name is made in English, then everything goes smoothly. Such is the problem.

    1 answer 1

    According to MSDN, the SHFILEOPSTRUCT structure declares fields

     LPCTSTR pFrom; LPCTSTR pTo; 

    as strings of type LPCTSTR, not LPCSTR. Therefore, string conversion should be different.

     SHF.pFrom = slSourceDir1.t_str(); SHF.pTo = slTargetDir1.t_str(); 

    And the project should be Unicode. Somewhere else in the C ++ Builder setup, there is an option "TCHAR maps to" that can affect string conversions.