C++ Copy files

Started by
8 comments, last by MattMcC 21 years, 7 months ago
Hey, i want to make a program to copy save game files to a floppy. Though the name of the save files are different on very comp, each save file has a letter at the start of the file name hich is always te same but has 5 different numbers after. Also what is the a function in C++ to copy files? Thanks.
Advertisement
okay... try this funcs

FileFindFirst
FileFindNext (maybe it''s FindFileNext)

to cpoy a file there is a shell function SHFileOperation I guess... if you don''t want to use windows, you have to load it and the save it somewhere else manually I guess...

If you have problems constructing the filename, try something like

char buffer[1000];

sprintf(buffer,"x%05d.ext", number);

this could give you x00004.ext for number = 4

good luck
Luckily the to files i need 2 copy are the only ons in th folder with .erc extensions . Although i don't really want to se Win32 just plain C++ .

[edited by - MattMcC on August 30, 2002 8:41:30 AM]
You could always use

system("copy file1 a:");

or something like that... build up the command string using sprintf as Caesar said.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
Is there any articles etc i could read, can''t fnd much on google and im only a begginer o it''s quite confusing.
If this is for a game you''ve bought, just write a batch (.bat) file and put it in the game''s directory.

something like this

copy a*.erc a:\

where ''a'' is the prefix letter

____________________________________________________________
www.elf-stone.com

____________________________________________________________www.elf-stone.com | Automated GL Extension Loading: GLee 5.00 for Win32 and Linux

yea it is a game i have bought an it''s installed in it''s own directory.

Thanks but now im completely lost \></
Is there any articles anyhere that would help, or could someone right a little more code plz, sorry for all the hasle.
fread() and fwrite().
The Win32 API has a CopyFile() function.

This topic is closed to new replies.

Advertisement