943,513 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 50974
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Jun 4th, 2003
1

Syntax for deleting specified file ( in C++)

Expand Post »
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?
Similar Threads
Reputation Points: 13
Solved Threads: 0
Light Poster
Mr Gates is offline Offline
36 posts
since May 2003
Jun 4th, 2003
0
Re: Syntax for deleting specified file ( in C++)
If you're writing a Windows application, try the DeleteFile function available in winbase.h:

C++ Syntax (Toggle Plain Text)
  1. BOOL DeleteFile(
  2. LPCTSTR lpFileName // pointer to name of file to delete
  3. );
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 162
The Queen of DaniWeb
cscgal is online now Online
13,645 posts
since Feb 2002
Jun 5th, 2003
-1
Re: Syntax for deleting specified file ( in C++)
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?
Reputation Points: 13
Solved Threads: 0
Light Poster
Mr Gates is offline Offline
36 posts
since May 2003
Jun 11th, 2003
1
Re: Syntax for deleting specified file ( in C++)
To delete a file use the C++ remove() function.
Bob
Team Colleague
Reputation Points: 15
Solved Threads: 2
Junior Poster
Bob is offline Offline
129 posts
since Feb 2003
Jun 11th, 2003
0
Re: Syntax for deleting specified file ( in C++)
thanks Bob
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 162
The Queen of DaniWeb
cscgal is online now Online
13,645 posts
since Feb 2002
Jun 12th, 2003
0

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

You're welcome.

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

[img]http://www.robertjacobs.fsnet.co.uk/images/dani2.jpg[/img]
Bob
Team Colleague
Reputation Points: 15
Solved Threads: 2
Junior Poster
Bob is offline Offline
129 posts
since Feb 2003
Jun 12th, 2003
0

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

Oh, goodness gracious! I guess it would be most appropriate to make this my 667th post then.
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 162
The Queen of DaniWeb
cscgal is online now Online
13,645 posts
since Feb 2002
Jun 12th, 2003
0

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

Are those suppose to be horns? They look like donkey ears.
Team Colleague
Reputation Points: 262
Solved Threads: 18
a.k.a inscissor
samaru is offline Offline
1,227 posts
since Feb 2002
Jun 12th, 2003
0

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

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.


C++ Syntax (Toggle Plain Text)
  1. #include <stdlib.h> // needed to use system() function
  2.  
  3. int main() {
  4. system("del dafile.txt");
  5. return 0;
  6. }
Team Colleague
Reputation Points: 262
Solved Threads: 18
a.k.a inscissor
samaru is offline Offline
1,227 posts
since Feb 2002
Jun 17th, 2003
0

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

Ebil cscgal

Anyway, how would I do that so it deleted the file at closing?
Reputation Points: 13
Solved Threads: 0
Light Poster
Mr Gates is offline Offline
36 posts
since May 2003
Message:
Previous Thread in C++ Forum Timeline: fgets() keep skipping a line after cout.
Next Thread in C++ Forum Timeline: offsetting sprites in c++





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC