|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
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.
Thanks 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 ![]() |
|
#2
|
||||
|
||||
|
See the CopyFile() and CopyFileEx() documentation in MSDN
There should be no problems in using spaces in filenames with these functions. |
|
#3
|
|||
|
|||
|
oh sweet thanks
|
|
#4
|
|||
|
|||
|
Hi, Sorry if i should newb but in order to copy a file, i have this code..
Code:
BOOL CopyFile( LPCTSTR lpExistingFileName, LPCTSTR lpNewFileName, BOOL bFailIfExists ); but... do i just leave lpExistingFileName as that? or do i change it with like C:\Whatever\I\Want\To\Copy Thanks in advance. -Kyle |
|
#5
|
||||
|
||||
|
My experience, which is limited, is that you need to use double backslashes because of real expressions.
Example: C:\\Whatever\\I\\Want\\To\\Copy Eric |
|
#6
|
|||
|
|||
|
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 ? Thanks. |
|
#8
|
||||
|
||||
|
You can just use something like this:
Code:
CopyFile("C:\\path\\to\\source\\file", "C:\\path\\to\\destination\\file", FALSE);
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. |
|
#9
|
|||
|
|||
|
Ok, Thanks a lot
![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > Copy a file? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|