Can't delete file on harddrive!

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2005
Posts: 14
Reputation: bombe is an unknown quantity at this point 
Solved Threads: 1
bombe bombe is offline Offline
Newbie Poster

Can't delete file on harddrive!

 
0
  #1
Feb 17th, 2005
Hi viewers,
I was trying to delete a file from my hard drive and I don't really have a good place to start. I googled it and came up with a code derived from multiple sources. I was wondering if anyone could help me out with the code to delete files from anywhere in your hard drive. Doesn't matter what file it is because this code is for a bigger program i'm trying to create. Here's my code so far...

  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <windows.h>
  4. using namespace std;
  5.  
  6. int APIENTRY WinMain(HINSTANCE hInstance,
  7. HINSTANCE hPrevInstance,
  8. LPSTR lpCmdLine,
  9. int nCmdShow);
  10.  
  11. int main()
  12. {
  13. cout <<"Deleting file...";
  14.  
  15. system("del C:\Program Files\filedel.txt");
  16.  
  17. MessageBox(NULL, "File Deleted!", "Alert!", NULL);
  18. return 0;
  19. }

If you guys could give me any ideas or suggestions i would greatly appreciate it. thx.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 30
Reputation: Intel is an unknown quantity at this point 
Solved Threads: 1
Intel Intel is offline Offline
Light Poster

Re: Can't delete file on harddrive!

 
0
  #2
Feb 17th, 2005
Lazy way to do it:
First strore the file name and location in a string. Append to this string 'del ' at the beginning. Execute the 'System' stmt on that string.
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 15
Reputation: steveh is an unknown quantity at this point 
Solved Threads: 0
steveh steveh is offline Offline
Newbie Poster

Re: Can't delete file on harddrive!

 
0
  #3
Feb 17th, 2005
Originally Posted by bombe
Hi viewers,
I was trying to delete a file from my hard drive and I don't really have a good place to start. I googled it and came up with a code derived from multiple sources. I was wondering if anyone could help me out with the code to delete files from anywhere in your hard drive. Doesn't matter what file it is because this code is for a bigger program i'm trying to create. Here's my code so far...

  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <windows.h>
  4. using namespace std;
  5.  
  6. int APIENTRY WinMain(HINSTANCE hInstance,
  7. HINSTANCE hPrevInstance,
  8. LPSTR lpCmdLine,
  9. int nCmdShow);
  10.  
  11. int main()
  12. {
  13. cout <<"Deleting file...";
  14.  
  15. system("del C:\Program Files\filedel.txt");
  16.  
  17. MessageBox(NULL, "File Deleted!", "Alert!", NULL);
  18. return 0;
  19. }

If you guys could give me any ideas or suggestions i would greatly appreciate it. thx.
You can also use the function FileDelete("path"). "path" is a string containing the filename. This fxn also supports wildcards if you are not sure of the file's extension.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 1
Reputation: permoda is an unknown quantity at this point 
Solved Threads: 0
permoda permoda is offline Offline
Newbie Poster

Re: Can't delete file on harddrive!

 
0
  #4
Nov 29th, 2008
i can't apply this at Borland C
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