Hi,

I just want to copy a file to a destination and it doesn't work.
The Very simple code is :
#include "stdafx.h"
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
CopyFile((const unsigned short *)".\\toto.txt", (const unsigned short
*)".\\toto.bak", FALSE);
return 0;
}

I'm under Windows CE 5.0 and my IDE is Micorsoft eMbedded Visual C++ 4.

If I use the GetLastError() method, the code is 2 (ERROR_FILE_NOT_FOUND).
But toto.txt is present at the good place !!

what's wrong ??

Re: Error with CopyFile function by ctacke/>

ctacke/>
Thu Sep 14 09:45:57 CDT 2006

The fact you have to do that ugly cast to get it to compile should be a huge
clue that you're doing it wrong. You might want to read up on Unicode and
TCHAR macros. CE also doesn't have a working directory or relative paths.

CopyFile(_T("\\toto.txt"), T("\\toto.bak"), FALSE);



--
Chris Tacke
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--


"Nicolas" <Nicolas@discussions.microsoft.com> wrote in message
news:19A4555C-D4E6-4CC3-BD52-BB1505D34CB3@microsoft.com...
> Hi,
>
> I just want to copy a file to a destination and it doesn't work.
> The Very simple code is :
> #include "stdafx.h"
> int WINAPI WinMain( HINSTANCE hInstance,
> HINSTANCE hPrevInstance,
> LPTSTR lpCmdLine,
> int nCmdShow)
> {
> CopyFile((const unsigned short *)".\\toto.txt", (const unsigned short
> *)".\\toto.bak", FALSE);
> return 0;
> }
>
> I'm under Windows CE 5.0 and my IDE is Micorsoft eMbedded Visual C++ 4.
>
> If I use the GetLastError() method, the code is 2 (ERROR_FILE_NOT_FOUND).
> But toto.txt is present at the good place !!
>
> what's wrong ??



Re: Error with CopyFile function by Nicolas

Nicolas
Fri Sep 15 02:39:02 CDT 2006

thx a lot!

as you can see i'm not a wince developper :)

Now i know i've unicode problem in my code, and i could search for resolv it.

thx again.

"<ctacke/>" wrote:

> The fact you have to do that ugly cast to get it to compile should be a huge
> clue that you're doing it wrong. You might want to read up on Unicode and
> TCHAR macros. CE also doesn't have a working directory or relative paths.
>
> CopyFile(_T("\\toto.txt"), T("\\toto.bak"), FALSE);
>
>
>
> --
> Chris Tacke
> OpenNETCF Consulting
> Managed Code in the Embedded World
> www.opennetcf.com
> --
>
>
> "Nicolas" <Nicolas@discussions.microsoft.com> wrote in message
> news:19A4555C-D4E6-4CC3-BD52-BB1505D34CB3@microsoft.com...
> > Hi,
> >
> > I just want to copy a file to a destination and it doesn't work.
> > The Very simple code is :
> > #include "stdafx.h"
> > int WINAPI WinMain( HINSTANCE hInstance,
> > HINSTANCE hPrevInstance,
> > LPTSTR lpCmdLine,
> > int nCmdShow)
> > {
> > CopyFile((const unsigned short *)".\\toto.txt", (const unsigned short
> > *)".\\toto.bak", FALSE);
> > return 0;
> > }
> >
> > I'm under Windows CE 5.0 and my IDE is Micorsoft eMbedded Visual C++ 4.
> >
> > If I use the GetLastError() method, the code is 2 (ERROR_FILE_NOT_FOUND).
> > But toto.txt is present at the good place !!
> >
> > what's wrong ??
>
>
>