Syntax for deleting specified file ( in C++)

Reply

Join Date: May 2003
Posts: 36
Reputation: Mr Gates is an unknown quantity at this point 
Solved Threads: 0
Mr Gates Mr Gates is offline Offline
Light Poster

Syntax for deleting specified file ( in C++)

 
1
  #1
Jun 4th, 2003
I've made a program that creates a log of the activities performed in it, for easy reference for the user. But I want the program to automatically delete the file after the program is shut down. What is the syntax and how do I go about doing it?
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,027
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 126
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb
 
0
  #2
Jun 4th, 2003
If you're writing a Windows application, try the DeleteFile function available in winbase.h:

  1. BOOL DeleteFile(
  2. LPCTSTR lpFileName // pointer to name of file to delete
  3. );
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: May 2003
Posts: 36
Reputation: Mr Gates is an unknown quantity at this point 
Solved Threads: 0
Mr Gates Mr Gates is offline Offline
Light Poster
 
0
  #3
Jun 5th, 2003
the program was written to run in command prompt/dos, and I still can't get it to work. any other suggestions?

Say I tried to do it with windows, where would I specify the file I wanted to be deleted with the syntax you just gave me?
Reply With Quote Quick reply to this message  
Join Date: Feb 2003
Posts: 129
Reputation: Bob is an unknown quantity at this point 
Solved Threads: 1
Team Colleague
Bob Bob is offline Offline
Team Member
 
1
  #4
Jun 11th, 2003
To delete a file use the C++ remove() function.
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,027
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 126
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb
 
0
  #5
Jun 11th, 2003
thanks Bob
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Feb 2003
Posts: 129
Reputation: Bob is an unknown quantity at this point 
Solved Threads: 1
Team Colleague
Bob Bob is offline Offline
Team Member

Re: Syntax for deleting specified file ( in C++)

 
0
  #6
Jun 12th, 2003
You're welcome.

Now, please post again. That 666 (posts) is making me uneasy ;-)

http://www.robertjacobs.fsnet.co.uk/images/dani2.jpg
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,027
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 126
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

Re: Syntax for deleting specified file ( in C++)

 
0
  #7
Jun 12th, 2003
Oh, goodness gracious! I guess it would be most appropriate to make this my 667th post then.
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 1,135
Reputation: samaru is just really nice samaru is just really nice samaru is just really nice samaru is just really nice 
Solved Threads: 5
Team Colleague
samaru's Avatar
samaru samaru is offline Offline
a.k.a inscissor

Re: Syntax for deleting specified file ( in C++)

 
0
  #8
Jun 12th, 2003
Are those suppose to be horns? They look like donkey ears.
Check out my blog at http://www.shinylight.com for more stuff about web dev.
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 1,135
Reputation: samaru is just really nice samaru is just really nice samaru is just really nice samaru is just really nice 
Solved Threads: 5
Team Colleague
samaru's Avatar
samaru samaru is offline Offline
a.k.a inscissor

Re: Syntax for deleting specified file ( in C++)

 
0
  #9
Jun 12th, 2003
An easy way to delete a file is to just call a system command from Windows. dafile.txt is the file you want to delete.


  1. #include <stdlib.h> // needed to use system() function
  2.  
  3. int main() {
  4. system("del dafile.txt");
  5. return 0;
  6. }
Check out my blog at http://www.shinylight.com for more stuff about web dev.
Reply With Quote Quick reply to this message  
Join Date: May 2003
Posts: 36
Reputation: Mr Gates is an unknown quantity at this point 
Solved Threads: 0
Mr Gates Mr Gates is offline Offline
Light Poster

Re: Syntax for deleting specified file ( in C++)

 
0
  #10
Jun 17th, 2003
Ebil cscgal

Anyway, how would I do that so it deleted the file at closing?
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



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC