CopyFile && Win2000

CopyFile && Win2000

Post by Rene » Wed, 10 Apr 2002 11:57:25



Hi,

I have an interesting question belonging to WinJ2k.

In my current Win32-proggie I want to copy a file.
Normaly I do this with CopyFile(src, dst, false), and this works fine
in the debug-build. The problem is that the Release-Version doesn't
work properly. The function return successfully with 1, but the file
isn't copied. Even (if the dst wasn't empty) the dst-file is
removed!!! So, this can't be a problem with my security-restrictions
of the account (by the way, I use the root-account!)

What's the problem? I've read the former postings to this problem but
they answer the question not specifically!

If anyone has some remarks...
thanks guys
Rene'

 
 
 

CopyFile && Win2000

Post by Günter Nagle » Thu, 11 Apr 2002 21:02:52



> I have an interesting question belonging to WinJ2k.

> In my current Win32-proggie I want to copy a file.
> Normaly I do this with CopyFile(src, dst, false), and this works fine
> in the debug-build. The problem is that the Release-Version doesn't
> work properly. The function return successfully with 1, but the file
> isn't copied. Even (if the dst wasn't empty) the dst-file is
> removed!!! So, this can't be a problem with my security-restrictions
> of the account (by the way, I use the root-account!)

> What's the problem? I've read the former postings to this problem but
> they answer the question not specifically!

> If anyone has some remarks...

maybe filenames have not full path and assume certain current directory which
can be different for debug and release build.
Output the filenames and working directory before copying with MessageBox or
write them to a file.
It can't be a security problem if it works in debug mode.

In worst case file handle could be destroyed by some code before and don't let
access files properly anymore.
But usually it is a problem of wrong file path, use full pathnames for both
filenames in CopyFile.

Check the GetLastError code after copy and see what it means.
3rd parameter of CopyFile is important to set correctly (allow overwrite if
existing).

 
 
 

CopyFile && Win2000

Post by Rene » Fri, 12 Apr 2002 18:25:51




> > I have an interesting question belonging to WinJ2k.

> > In my current Win32-proggie I want to copy a file.
> > Normaly I do this with CopyFile(src, dst, false), and this works fine
> > in the debug-build. The problem is that the Release-Version doesn't
> > work properly. The function return successfully with 1, but the file
> > isn't copied. Even (if the dst wasn't empty) the dst-file is
> > removed!!! So, this can't be a problem with my security-restrictions
> > of the account (by the way, I use the root-account!)

> > What's the problem? I've read the former postings to this problem but
> > they answer the question not specifically!

> > If anyone has some remarks...

> maybe filenames have not full path and assume certain current directory which
> can be different for debug and release build.
> Output the filenames and working directory before copying with MessageBox or
> write them to a file.
> It can't be a security problem if it works in debug mode.

> In worst case file handle could be destroyed by some code before and don't let
> access files properly anymore.
> But usually it is a problem of wrong file path, use full pathnames for both
> filenames in CopyFile.

> Check the GetLastError code after copy and see what it means.
> 3rd parameter of CopyFile is important to set correctly (allow overwrite if
> existing).

Hi...

Thanks for the answer...
Well, I fixed it and the problem was.....
...instead of passing a char * to CopyFile() I passed a CString *
pointer. This results in the (absolutely crazy) behaviour described
above. By the way, the debug-version works fine, anyway. I came across
with the problem by checking a CopyFile()-Call in another proggie, and
this one worked fine(same account and files). Thaks again for your
answer
Rene'

 
 
 

1. книга c\с++

нужны
линки на subj
(не visual)по
программированию
сокетов и
для
написания
софта для tcp\ip
и вообще
для сети(!!!не
локально-вычислительных).
ответы
кидать на

2. how to plunge myself into c++ when in java's sea?

3. &&& Moles and Mazes &&&

4. Why do some programs come up as truncated windows?

5. مثففشق

6. Connection pooling in webservice.

7. учебник по с\с++

8. How to get LPT status and 1284id of the printer?

9. 推荐一个C++论坛 (C++探路者) http://cpp.aosee.com/

10. 3 monitors & win2000 & maximized

11. HELP: AttachThreadInput () && Keyboard && TListItem ???

12. MSDN&WIN95&MFC&BORLAND&DE

13. Meaning of HDN_DIVIDERDBLCLICKW & WM_KEYDOWN ((wParam == VK_ADD && GetKeyState(VK_CONTROL) & 0x80)???