473,399 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Deleting a file


Hello all,

Back in C, the remove() API was the language standard way to remove a file.
I have not been able to find a similar facility in the streams classes. Can
anyone tell me if such a facility exists?

I'd rather not resort to the old C API or use a non-standard API unless it's
necessary...

Thanks,
Dave

Jul 19 '05 #1
5 7967
"Dave Theese" <ch**********@yahoo.com> wrote in message
news:3f***********************@news.twtelecom.net. ..
| Back in C, the remove() API was the language standard way to remove a
file.
| I have not been able to find a similar facility in the streams classes.
Can
| anyone tell me if such a facility exists?
None that I am aware of.

| I'd rather not resort to the old C API or use a non-standard API unless
it's
| necessary...

The "old C API" is wrapped for C++ by including cstdio. Then call
std::remove(). C++ programmers are constantly using the C library for such
things, and that was the intention by keeping it (besides regression and
backwards compatibility).
Jul 19 '05 #2
Dave Theese wrote:
Hello all,

Back in C, the remove() API was the language standard way to remove a file.
That is also true in C++.

This:
///////////////////
#include <cstdio>
#include <cstdlib>

using namespace std;

int main() {
if (remove("somefile.txt")) {
perror("remove");
exit(1);
}
return 0;
}
//////////////////

Is a valid C++ program.
I have not been able to find a similar facility in the streams classes. Can
anyone tell me if such a facility exists?
Nothing in the streams classes, no.
I'd rather not resort to the old C API or use a non-standard API unless it's
necessary...


Why not? I can understand why you'd prefer using the streams classes
over C I/O, but why for deleting files?

- Adam

Jul 19 '05 #3
"Adam Fineman" <aB**************@KcIoNmGpSuter.org> wrote in message
news:Ah****************@news.uswest.net...
| Why not? I can understand why you'd prefer using the streams classes
| over C I/O...

I can't <g>
Jul 19 '05 #4
"Adam Fineman" <aB**************@KcIoNmGpSuter.org> wrote in message
news:XX****************@news.uswest.net...
| For those of you who would say this without the '<g>':
| http://parashift.com/c++-faq-lite/input-output.html

The only reason for me not liking iostreams is the bulkiness of it (at least
the compilers I've used: msvc, borland, intel, digital mars, gcc) compared
to the C equivalents. But this is just my opinion, and I know that with the
added object footprint comes excellent type-safety and all that good stuff.
I guess that I am just too accustomed to using the printf/scanf family. Also
I know that Bjarne states on his website
(http://www.research.att.com/~bs/bs_faq.html#Hello-world) stating that it's
all in the implementation...I just haven't found a good C++ std lib that
does just that.

I've seen wars errupt over such controversial subject and I am not attemping
to start one, just stating my opinion. For beginners iostreams is almost a
must as it does most the the error checking for them. For seasoned
developers and small projects, being *one* with your code prevents any
errors at all omitting the need for the iostreams checking.

Oh, and another thing, the overloaded left and right shift operators bug me
that they are used for something other than bit shifting =)
Jul 19 '05 #5
Dave Theese wrote:
Hello all,

Back in C, the remove() API was the language standard way to remove a file.
I have not been able to find a similar facility in the streams classes. Can
anyone tell me if such a facility exists?

I'd rather not resort to the old C API or use a non-standard API unless it's
necessary...


remove() is a function, not an API. And it's the only thing that I know
of that exists in C++ that allows anything remotely similar to what you
want to do.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.

Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Bob Darlington | last post by:
I have a repair and backup database routine which runs when a user closes down my application. It works fine in my development machine, but breaks on a client's at the following line: If...
4
by: al havrilla | last post by:
hi all what does the phrase: "scalar deleting destructor" mean? i'm getting this in a debug error message using c++ 7.1 thanks Al
2
by: GMK | last post by:
Dear all in my asp.net application i have a text file that is installed with my application on the server. this text file is filled with data through a web interface in my application. i need to...
5
by: George | last post by:
VB.net 2003 standard, XP windows home edition. Installed first application OK today. When I removed the application via Control Panel, there were no problems and the app folders were deleted. ...
8
by: shandra | last post by:
I have a file I need to delete or truncate. I tried using the KILL command in VB6. I tried using the file.delete command in VB.net. I tried manually deleting, renaming, and copying over the...
2
by: SiouxieQ | last post by:
Hi there, I'm using the code below to try to delete a name from a list of names in a file. Unfortunately it doesn't quite do what I want it to. Instead of looking for the name in the...
5
by: Sandeep Singh Sekhon | last post by:
I am Developing a Web Application with ASP.NET 1.1 I have one project Folder which is virtual directory of IIS. In this directory, I have one Folder named Photos in which I used to Store Photos....
3
by: Kimera.Kimera | last post by:
I'm trying to write a program in VB.net 2003 that basically deletes all files, folders, sub-folders and sub-sub folders (etc). The program is simply for deleting the Windows/Temp folder contents,...
13
by: programming | last post by:
how do i delete from a text file 1 of the following lines: jon|scott adam|smith <--delete paul|clark say i would like to delete the middle line of this txt, in member.txt what php code or...
1
by: diyasher | last post by:
hello my code is in c#. i am using fileSystemWatcher class to watch event when file is deleted. event is fire when file is deleted, i want to stop deleting file, means when user want to delete...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.