Discussion:
CopyFile and AnsiStrings
(too old to reply)
dsmey
2009-10-22 18:09:18 UTC
Permalink
Hi all,

Just updated from CBuilder 2006 to 2009. I've got a junky little app
that moves files around and renames them. But, now it won't compile.
The line:

CopyFile(Alist->Strings[i].c_str(), filename.c_str(), false);

throws the error Cannot convert 'wchar_t *' to 'const char *'

Alist is a StringList and filename is an AnsiString

So it looks like I need some basic string help. My AnsiStrings are
now widestrings? Or only after I call the .c_str() method?

To make it more confusing, using CopyFileA gives error Cannot convert
wchar_t * to const char *, but using CopyFileW give Cannot convert
char * to const wchar_t * (which is the exact opposite)?

Any help would be appreciated.
dsmey
2009-10-22 21:03:09 UTC
Permalink
Post by dsmey
To make it more confusing, using CopyFileA gives error Cannot convert
wchar_t * to const char *, but using CopyFileW give Cannot convert
char * to const wchar_t * (which is the exact opposite)?
OK, I think I figured it out. The string from the stringlist is a
UnicodeString, thus the error with CopyFileA. The other AnsiString is
just a narrow string, thus the error with CopyFileW. If I "upconvert"
the narrow string to unicode and use CopyFileW I should be in
business.

Loading...