cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
how to delete a file using c++?
how to delete a file using c++?
Jul 6, 2014 at 2:10am UTC
Furyoku
(8)
how to delete a file in c++
I already look here:
http://www.cplusplus.com/reference/cstdio/remove/
but still don't unsderstand.
for example i want to delete a .exe or .txt file.
Jul 6, 2014 at 2:16am UTC
bigorenski
(40)
Try this:
#include <cstdio>
const char* file_to_delete = "c:\samplefile.exe"
std::remove(file_to_delete);
The user running the program should have permission to delete that file(be admin or so)...
Last edited on
Jul 6, 2014 at 2:18am UTC
Jul 6, 2014 at 2:20am UTC
TwilightSpectre
(1392)
You should also put some checks in to determine whether or not the file was actually deleted, and what to do in that case. The example on the page you referenced showed a good example of how to do that.
Topic archived. No new replies allowed.