I have a string that has multiple file paths like as shown below:
%programdata%\EMR\Registration\Registration_EMR.xml C:\ProgramData\EMR\Registration\RegistrationEMR.xml
%AppData%\EMR\EMR Setup\REGDATA\registration_EMR.xml %AppData%\EMR\EMR Setup\REGDATA\RegistrationEMR.xm
I wanted to loop through the string by separating the file paths with space(' ') and store it into the vector/array.
so that the vector/array contains the below path that is separated with space.
%programdata%\EMR\Registration\Registration_EMR.xml
C:\ProgramData\EMR\Registration\RegistrationEMR.xml
%AppData%\EMR\EMR Setup\REGDATA\registration_EMR.xml
%AppData%\EMR\EMR Setup\REGDATA\RegistrationEMR.xml
Could anyone please help me?
Updated code:
I modified the ReadJsonFile function like as shown below to split the file paths after each .xml, then calling ExpandEnvironmentStrings and then storing each file path into the vector.
I am facing difficulty to tokenize the string as we can tokenize only char*.
I am getting the below errors:
argument of type "const WCHAR *" is incompatible with parameter of type "char *" no instance of overloaded function "ExpandEnvironmentStringsW" matches the argument list
bool EMRFileReader::ReadJsonFile(const std::wstring &strFilePath, std::wstring &strFileContent)
{
std::vector<std::wstring> pathsVector;
const WCHAR *wpszPathToSearch = strFilePath.c_str();
TCHAR szOut[MAX_PATH];
char *token = strtok(wpszPathToSearch, ".xml");
//argument of type "const WCHAR *" is incompatible with parameter of type "char *"
while (token != NULL)
{
ExpandEnvironmentStrings(token, szOut, ARRAYSIZE(szOut));
//no instance of overloaded function "ExpandEnvironmentStringsW" matches the argument list
pathsVector.push_back(szOut);
}
return true;
}