GetCurrentDirectory + '\\'
Hi all,
If I use GetCurrentDirectory to get the current path for creating a file, it returns an un-escaped path causing an error.
How can I easily get the current directory with escaped '\' i.e.
c:\\my\\path
rather than
c:\my\path
Or am I just being stupid.
TIA, rotis23
Re: GetCurrentDirectory + '\\'
Quote:
Originally posted by rotis23
Hi all,
If I use GetCurrentDirectory to get the current path for creating a file, it returns an un-escaped path causing an error.
How can I easily get the current directory with escaped '\' i.e.
c:\\my\\path
rather than
c:\my\path
Or am I just being stupid.
TIA, rotis23
To explain where your thinking went wrong - the slashes that exist in the path have already 'been escaped'. Just because the C/C++ language (and apparently the code for this forum) uses '\\' as an escape character prefix for other unprintable characters, it means that it now has to use something else for a real '\\' - they chose '\\\'. So, when you type '\\\', you are not making a string with '\\\' (i.e. 2 characters), you are making a string with '\\' (i.e. 1 character). I hope that helps your understanding a bit.