[RESOLVED] How to turn backslash to forward slash in windows environmental variable?
I necessarily need to change backslash to forward slash in windows environmental variable. Do you have any suggestions how can I get %programdata% path with forward slash after systemDrive?
Code:
TCHAR path[_MAX_PATH];
_tcscpy(path, programdata);
_tcscat(path, _T("\\myfile.txt"));
Re: How to turn backslash to forward slash in windows environmental variable?
I found a way. Not very comfortable though.
Solved:
Code:
TCHAR path[_MAX_PATH];
_tcscpy(path, systemdrive);
_tcscat(path, _T("/programdata"));
Re: How to turn backslash to forward slash in windows environmental variable?
No, it's not a solution because programdata is not always the system drive subfolder:(
Re: How to turn backslash to forward slash in windows environmental variable?
Solved:
Code:
typedef std::basic_string<TCHAR> tstring;
tstring pathbasic = tstring(programdata) + _T("\\myfile.txt");
std::replace(pathbasic.begin(), pathbasic.end(), _T('\\'), _T('/'));
Re: [RESOLVED] How to turn backslash to forward slash in windows environmental variab
Why are you using environment variables when there are apis to retrieve this data?
Re: [RESOLVED] How to turn backslash to forward slash in windows environmental variab
Actually, this didn't help me. I spent a lot of time to understand that API I used does not recognize non-latin letters.
Re: [RESOLVED] How to turn backslash to forward slash in windows environmental variab
Quote:
Originally Posted by
prako2
Actually, this didn't help me. I spent a lot of time to understand that API I used does not recognize non-latin letters.
My point is there are api's (at least on Windows) that render using environment variables unnecessary and obsolete. The replacment api's (like other Windows apis) also support UNICODE.