Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CopyFile and AnsiStrings

86 views
Skip to first unread message

dsmey

unread,
Oct 22, 2009, 2:09:18 PM10/22/09
to
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

unread,
Oct 22, 2009, 5:03:09 PM10/22/09
to
>
> 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.
0 new messages