How could do delete any files within C++? Like you run an .exe and some files are deleted, like a game save or something.......example
c:\games\player1.txt
and then you want to delete that file.
How could do delete any files within C++? Like you run an .exe and some files are deleted, like a game save or something.......example
c:\games\player1.txt
and then you want to delete that file.
There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!
"...The only real game I thank in the world is baseball..." --Babe Ruth
"Life is beautiful"-Don Corleone right before he died.
"The expert on anything was once a beginner" -Baseball poster I own.
Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.
system("del c:/games/player1.txt");
I'm sure there are better ways though.
Thank you.
There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!
"...The only real game I thank in the world is baseball..." --Babe Ruth
"Life is beautiful"-Don Corleone right before he died.
"The expert on anything was once a beginner" -Baseball poster I own.
Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.
Or use remove().
remove("c:\\games\\player1.txt");
Don't forget you need two backslahes to represent one backslash. Or you can use the forward slash, as Dual-Catfish shows.
Sorry to bring this up again, but instead of starting a whole new thread I decided to just bump it. How would I delete a whole directory? like ....c:\oldgamefiles\
There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!
"...The only real game I thank in the world is baseball..." --Babe Ruth
"Life is beautiful"-Don Corleone right before he died.
"The expert on anything was once a beginner" -Baseball poster I own.
Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.
You have to use a function called findnext or something like that. This will find the next file. From here, you can delete the file. Once you have deleted all files inside the directory, you can delete the directory.
I thought it was:
// for Windows. deltree.exe is found in .../Windows/Command/...
system(deltree 'directory');
//use the following to get additional info on deltree.exe
system(deltree /?);
think only with code.
write only with source.
Thank you guys.
There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!
"...The only real game I thank in the world is baseball..." --Babe Ruth
"Life is beautiful"-Don Corleone right before he died.
"The expert on anything was once a beginner" -Baseball poster I own.
Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.
#include <iostream>
#include <conio.c> // Thats in Dev-C++4
#include <stdlib.h>
#include <stdio.h>
#include <string>
void main()
{
string directory="C:\\games\files\";
remove(directory);
cin.get();
}
Compiler: MingW(IDE: Bloodshed Dev-C++ 4.01)
Web Site: Zoo Crew
Forums: Zoo Boards
E-mail: [email protected]
"Do you wanna go to jail or do you wanna go home?!?!" - Alonzo(Training Day)
Originally posted by toaster
I thought it was:
// for Windows. deltree.exe is found in .../Windows/Command/...
system(deltree 'directory');
//use the following to get additional info on deltree.exe
system(deltree /?);
Would this delete the folder directory or just the files within the folder? How would I go about emptying the contents of a folder and leaving the folder. One more thing what website could I find this neat little "tricks"? because I dont' see any of these things in books.
There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!
"...The only real game I thank in the world is baseball..." --Babe Ruth
"Life is beautiful"-Don Corleone right before he died.
"The expert on anything was once a beginner" -Baseball poster I own.
Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.