September 20th, 2002, 12:56 AM
Copy a file?
Hi i was wondering if anyone knew how I can copy a file (with C++) and then place it in a folder and overwrite a file in that folder with the same name.
Edit: Oh yea, and i was wondering how i could open a file that has a space in the folder name like.. C:\Documents and Settings\default\My Documents how can i write that in C++ Coz it doesnt let me do spaces :(
September 20th, 2002, 04:54 PM
See the CopyFile() and CopyFileEx() documentation in MSDN
There should be no problems in using spaces in filenames with these functions.
September 21st, 2002, 03:38 PM
September 23rd, 2002, 09:42 PM
Hi, Sorry if i should newb but in order to copy a file, i have this code..
but... do i just leave lpExistingFileName as that? or do i change it with like C:\Whatever\I\Want\To\Copy
Thanks in advance.
September 23rd, 2002, 10:03 PM
My experience, which is limited, is that you need to use double backslashes because of real expressions.
September 24th, 2002, 12:41 AM
Yea i know but what i mean is like how do i tell the program the path to the file? do i go like
#define lpExistingFileName C:\\*******
or what ?
September 24th, 2002, 08:04 AM
Here is a good example...
September 24th, 2002, 07:37 PM
You can just use something like this:
If you don't understand what this LPCTSTR business is all about, I suggest you research Hungarian Notation on the web, or look it up in a Visual C++ programming book. Practically all of Micro$oft's code uses Hungarian Notation as their standard naming convention and it's good to become slightly familiar with it.
CopyFile("C:\\path\\to\\source\\file", "C:\\path\\to\\destination\\file", FALSE);
September 24th, 2002, 09:47 PM