How to delete the file in the middle of a program

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2008
Posts: 105
Reputation: guest7 is an unknown quantity at this point 
Solved Threads: 0
guest7 guest7 is offline Offline
Junior Poster

How to delete the file in the middle of a program

 
0
  #1
Apr 12th, 2009
Hi,

How can i delete the file in the middle of the program in C++

Thanks
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: How to delete the file in the middle of a program

 
0
  #2
Apr 12th, 2009
Originally Posted by guest7 View Post
Hi,
How can i delete the file in the middle of the program in C++
Probably in the same manner as in the program head or in the program tail: close all streams associated with the file then use remove(filepath) library function declared in <cstdio>.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 181
Reputation: adam1122 is an unknown quantity at this point 
Solved Threads: 28
adam1122 adam1122 is offline Offline
Junior Poster

Re: How to delete the file in the middle of a program

 
0
  #3
Apr 12th, 2009
boost::filesystem also provides remove as a portable means to delete a file.

http://www.boost.org/doc/libs/1_38_0...ions-functions
Last edited by adam1122; Apr 12th, 2009 at 6:08 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: How to delete the file in the middle of a program

 
0
  #4
Apr 12th, 2009
Originally Posted by adam1122 View Post
boost::filesystem also provides remove as a portable means to delete a file.
http://www.boost.org/doc/libs/1_38_0...ions-functions
Fortunately, the remove from <cstdio> is a standard library function so no need to fire a nuclear missile to kill a fly. It's an absolutely portable function
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 976
Reputation: MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice 
Solved Threads: 92
MosaicFuneral's Avatar
MosaicFuneral MosaicFuneral is offline Offline
Posting Shark

Re: How to delete the file in the middle of a program

 
0
  #5
Apr 12th, 2009
boost is unnecessary - anytime anyone suggest a usage.
"Jedenfalls bin ich überzeugt, daß der Alte nicht würfelt."
"I became very sensitive to what will happen to all this and all of us." -Two geniuses named Albert
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 181
Reputation: adam1122 is an unknown quantity at this point 
Solved Threads: 28
adam1122 adam1122 is offline Offline
Junior Poster

Re: How to delete the file in the middle of a program

 
0
  #6
Apr 12th, 2009
Originally Posted by MosaicFuneral View Post
boost is unnecessary - anytime anyone suggest a usage.
Are you serious? Far from true.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 181
Reputation: adam1122 is an unknown quantity at this point 
Solved Threads: 28
adam1122 adam1122 is offline Offline
Junior Poster

Re: How to delete the file in the middle of a program

 
0
  #7
Apr 12th, 2009
Originally Posted by ArkM View Post
Fortunately, the remove from <cstdio> is a standard library function so no need to fire a nuclear missile to kill a fly. It's an absolutely portable function
It's a great library that should be put to use. It may not be necessary in this case but there's nothing wrong with suggesting alternatives.

It would be perfectly reasonable to use in this case if the programmer has already put Boost in their toolkit.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 181
Reputation: adam1122 is an unknown quantity at this point 
Solved Threads: 28
adam1122 adam1122 is offline Offline
Junior Poster

Re: How to delete the file in the middle of a program

 
-1
  #8
Apr 12th, 2009
Originally Posted by adam1122 View Post
Are you serious? Far from true.
I should clarify here. Yes, Boost is unnecessary but so is cstdio in this context. But then so is the entire language of C++ or any other high-level language, for that matter.

Every library is there to make our life a little easier and so we don't have to re-invent the wheel everyday. Boost is a great example and should be put to use if someone finds it helpful.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 476
Reputation: nucleon has a spectacular aura about nucleon has a spectacular aura about 
Solved Threads: 91
nucleon's Avatar
nucleon nucleon is offline Offline
Posting Pro in Training

Re: How to delete the file in the middle of a program

 
0
  #9
Apr 12th, 2009
regexes can be worthwhile.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: How to delete the file in the middle of a program

 
-1
  #10
Apr 12th, 2009
Originally Posted by adam1122 View Post
I should clarify here. Yes, Boost is unnecessary but so is cstdio in this context. But then so is the entire language of C++ or any other high-level language, for that matter.

Every library is there to make our life a little easier and so we don't have to re-invent the wheel everyday. Boost is a great example and should be put to use if someone finds it helpful.
Let's come back to the OP. Is it a question like how to delete file with Boost library? Or it was How can i delete the file in the middle of the program in C++? Correct me, please, if I'm wrong and it was Boost-oriented queston.
Otherwise let's discuss all great (and not only great) libraries where remove file functions exist. Let's consider how to use the Great Boost Library instead STL for streams, big num libraries instead of builtin operator +(POD,POD) and so on...
Keep it simpler ...
Last edited by ArkM; Apr 12th, 2009 at 8:38 pm.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC