Click to See Complete Forum and Search --> : File operation / manipulation
htlv
December 9th, 2006, 04:05 PM
Hi, does anyone have an executable file or source code where i can perform such operations as delete, read, write, create, open on a file or folder by using the command prompt?
for example:
to delete a file
myprogram.exe delete file.txt
dcjr84
December 9th, 2006, 04:13 PM
As far as files go, you can do all of the above operations with standard C++. The only exception is deleting a file, which is OS dependent.
Have a look at this website (http://www.cppreference.com/cppio/index.html) for more information on reading, writing, creating, and opening files.
As far as directories go, there is no standard way to manipulate them in C++. You must use some external library to do so.
Have a look at boost::filesystem (http://www.boost.org/libs/filesystem/doc/index.htm) for doing such things. It supports almost all OS platforms, and is very useful :D
htlv
December 9th, 2006, 04:23 PM
Thanks for replying.
exterminator
December 9th, 2006, 11:12 PM
Why do you need another application to do this stuff?
There are direct commands to do those stuff - mkdir, cd/chdir, rm/del/erase, and editors that will help you with editing the files.
Take a look at the windows commands - http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx?mfr=true
They are themselves programs that come with the operating system. Is this what you want?
htlv
December 10th, 2006, 04:15 AM
I need the a simple source code of something like that so i can customize it for my own use.
dcjr84
December 10th, 2006, 07:40 PM
Download and use the boost::filesystem (http://www.boost.org/libs/filesystem/doc/index.htm) that I showed you if you want a portable solution.
It's free, supports almost all OS platforms, and very easy to use.
If you just plan on using this in Windows, just follow exterminators advice and execute the built-in windows programs from within your code to do such things.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.