• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Copy and Delete files in c++

imported_tamim

Junior Member
what is the easiest way to copy (i.e. duplicate) and delete files (txt lets say) in c++?

I'm looking in a book called C++ How To Program by Deitel....cant find a way to delete files. Thanks.
 
CopyFile
The CopyFile function copies an existing file to a new file.

BOOL CopyFile(
LPCTSTR lpExistingFileName,
// pointer to name of an existing file

LPCTSTR lpNewFileName, // pointer to filename to copy to
BOOL bFailIfExists // flag for operation if file exists
);

Parameters
lpExistingFileName
Pointer to a null-terminated string that specifies the name of an existing file.

lpNewFileName
Pointer to a null-terminated string that specifies the name of the new file.

bFailIfExists
Specifies how this operation is to proceed if a file of the same name as that specified by lpNewFileName already exists. If this parameter is TRUE and the new file already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds.


Return Values
If the function succeeds, the return value is nonzero.
DeleteFile
The DeleteFile function deletes an existing file.

BOOL DeleteFile(
LPCTSTR lpFileName // pointer to name of file to delete
);

Parameters
lpFileName
Pointer to a null-terminated string that specifies the file to be deleted.

Return Values
If the function succeeds, the return value is nonzero.
[/q
 
Back
Top