-
August 30th, 2019, 06:02 PM
#1
[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"));
Last edited by prako2; August 31st, 2019 at 04:39 AM.
-
August 30th, 2019, 07:07 PM
#2
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"));
Last edited by 2kaud; August 31st, 2019 at 08:02 AM.
-
August 31st, 2019, 04:20 AM
#3
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
-
August 31st, 2019, 07:38 AM
#4
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('/'));
Last edited by 2kaud; August 31st, 2019 at 08:03 AM.
-
September 6th, 2019, 10:12 PM
#5
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?
-
September 7th, 2019, 11:30 AM
#6
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.
-
September 7th, 2019, 12:05 PM
#7
Re: [RESOLVED] How to turn backslash to forward slash in windows environmental variab
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.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|