shaolinfunk
asked on
How do I delete a file?
Ok, every time I run my little application it leaves behind a text file called C:\debug.txt.
I would like my app to delete this.
What command/code do I need to use in VC++ to delete this file?
Thank you!
I would like my app to delete this.
What command/code do I need to use in VC++ to delete this file?
Thank you!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oh, I forgot to mention that you should close your file before deleting it.
ASKER
Works like a charm. Thanks phoffric!
You didn't mention how you open and close, but in case you need this, here is sample code from:
http://www.cplusplus.com/reference/iostream/ofstream/close/
http://www.cplusplus.com/reference/iostream/ofstream/close/
// ofstream::open
#include <fstream>
using namespace std;
int main () {
ofstream outfile;
outfile.open ("test.txt", ofstream::out | ofstream::app);
outfile << "This sentence is appended to the file content\n";
outfile.close();
return 0;
}
Anytime. :)
ASKER
yes, thank you for that additional info...i closed the file by using:
outfile.close();
outfile.close();
Open in new window