Computing.Net > Forums > Programming > C++ Delete files

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

C++ Delete files

Reply to Message Icon

Name: CWoodward
Date: February 10, 2007 at 20:44:35 Pacific
OS: Windows XP
CPU/Ram: Intel Celleron
Product: Dell
Comment:

I had and old batch file that I used to delete any file on my computer of the same name:

--DelFile.bat--
@ECHO OFF
FOR /F "TOKENS=*" %%F IN ('DIR /AD /B /S') DO DELETE %%F\Trash.txt
--DelFile.bat--

Recently, I've been trying to update most of my batch files to C++. I have figured out how to translate most of my other files in C++, but i cant figure out how to establish all of the folders on the computer. Any ideas?




Sponsored Link
Ads by Google

Response Number 1
Name: Guy
Date: February 12, 2007 at 14:46:18 Pacific
Reply:

To delete a file in open C++ code, you should just be able to, e.g.:

std::remove("abc.txt");

That assumes:

#include <cstdio>
#include <cstdlib>

For the directory sweep, you will need to revert to basic C stuff, directory manipulation is not provided by the C++ libraries. The routines required are defined by:

#include <dirent.h>

It provides necessary definitions for 'opendir', 'readdir', etc .....

For more information, and example code see:

http://www.informit.com/guides/cont...

Guy



0
Reply to Message Icon

Related Posts

See More


Cannot install VB Express... silent cmd shell from vbs...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: C++ Delete files

Batch File deleting files by date? www.computing.net/answers/programming/batch-file-deleting-files-by-date/13717.html

Batch File deleting files by date? www.computing.net/answers/programming/batch-file-deleting-files-by-date/15581.html

Delete Files Older Then x-Days www.computing.net/answers/programming/delete-files-older-then-xdays/15229.html