473,326 Members | 2,023 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,326 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 7965
"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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.