deleting a file
How would I go around deleting a file?? I know how to write, read , and open a file... but??
readfile.open("filename.suffix", ios::in);
opens a file for me to read it .. well of course that is if readfile is of ifstream type.. how would I delete a file?? or multiple files.. in truth I want to make a program that deletes everything in the internet explorer temp folder....
thanx in advance
BAHcows go moomoos go cow
Here''s what I would do.
I would use the keybd_event function and you could generate a Windows Key + E which would open Windows Explorer. Then you could use the FindWindow function to find Explorer and then you could find it''s submenus and move around in there find the file and the make your program goto File and Delete.
You could also use the same method using the Windows Find program and search for the file you''d like to delete and generate a right click on the file and delete it.
I''m sure there is a function or something that will simply delete a file for you, but it''s a lot more fun writing third party applications that do stuff in other people''s programs.
I don''t know if this would work or not, but you might be able to turn the place on the hard drive where the file is located into virtual memory and just overwrite it with 0''s or something. That''d be another fun project.
Take Care! Glad I could help!
***Disclaimer: The previous statements were made while under the influence of multiple controlled substances.***
I would use the keybd_event function and you could generate a Windows Key + E which would open Windows Explorer. Then you could use the FindWindow function to find Explorer and then you could find it''s submenus and move around in there find the file and the make your program goto File and Delete.
You could also use the same method using the Windows Find program and search for the file you''d like to delete and generate a right click on the file and delete it.
I''m sure there is a function or something that will simply delete a file for you, but it''s a lot more fun writing third party applications that do stuff in other people''s programs.
I don''t know if this would work or not, but you might be able to turn the place on the hard drive where the file is located into virtual memory and just overwrite it with 0''s or something. That''d be another fun project.
Take Care! Glad I could help!
***Disclaimer: The previous statements were made while under the influence of multiple controlled substances.***
That would be fun.. but unfortuntley.. I wouldnt even know how to start somthing like that.. My programing knowledge is just dos and a little direct x... Nothin much besides that.. well java... but i dont know enought to even say Im a java programmer
BAHcows go moomoos go cow
Sorry about that. It was just a joke. Are you trying to delete something in DOS or Windows? What compiler are you using? What lanuage are you using?
Try using remove.
#include <stdio.h>void main(void){ if(remove("filename.suffix") == -1) printf("Couldn''t delete file"); else printf("deleted");}
.entrox
You could use DeleteFile(). It''s a windows function so you have to include windows.h
quote:
You could use DeleteFile(). It''s a windows function so you have to include windows.h
...or you could use remove() or unlink() to stay portable.
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
I don''t think there is an OS-independent way to do it in C++, although the system call is trivial regardless of the OS.
How does that DeleteFile function work??
also what about that Remove("file.suffix")... do I have to creare the function Remove?? or is it included with something.. I also want to make sure i can set it to a particular path..not just where the program itself is located
also what about that Remove("file.suffix")... do I have to creare the function Remove?? or is it included with something.. I also want to make sure i can set it to a particular path..not just where the program itself is located
BAHcows go moomoos go cow
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement