how to manipulate files (move, delete, copy,etc) in C++

Hello everyone
Btw I am still new in C++, n i want to ask several question about it (maybe it seems stupid, but i really want to know about it). Does anyone know how to manipulate files (and also directory) in C++, ex move, delete, copy, cut, rewrite files, save text, etc, on windows environment? and does it need header "windows.h" for its operation??

and please explain briefly about the use of system("xxx") in programs and its affection in windows environment (note : xxx = anything)

i want to build a program based from explanation given by all of you guys ....thx 4 share
Last edited on
Managing files is an Operating System thing, hence you need to call OS functions to do it.

However, I recommend you to the Boost Filesystem library
http://www.boost.org/doc/libs/release/libs/filesystem/index.html
which provides a very nice, high-level, C++ interface for dealing with filesystem objects.

Hope this helps.
Last edited on
@Duoas
Can u explain more detail about the use of system("xxx") (ex : system ("CLS"), system ("PAUSE"), etc )...? I've ever seen before that this code can be used to modify a file too (4 ex: deleting files)....

I've read previous topic that discuss about the use of it, but i can't still catch it..
I don't understand the reason about why using that code will open security hole, and so on (that sounds bad).......

before that, thx 4 sharing....
by the way....i don't know what to do with Boost Filesystem library (since i am still newbie....).....can u help me with it too? hehehe
To install Boost, check out the instructions from the Boost site:
http://www.boost.org/

The system() function executes another program.
So, what if someone put a program named "pause.exe" on your computer that deletes all your files? That's a simplified version of the problem.

Anything that the shell can do (cmd.exe, or bash, sh, etc) you can do using system().

Hope this helps.
@Duoas
well, i still does not understand about the instruction......mybe you can enlight the instruction??
btw, instead of boost, why don't you suggest about the use of cstdio (stdio.h)?
and could u explain to me about how to delete the file in a certain directory, and how to force delete it?

i think this topic is not interesting, anyway....
Topic archived. No new replies allowed.