Simple Q: How do I delete a file?
I know there must be a simple function or something in C++ to delete files from disk but I cannot find it in the msdn because other than delete I just dont know what keyword to search for (and delete just brings up info on new/delete).
If anyone could point me in the right direction Id be very grateful.
p.s. Its an mfc sdi app- don''t know whether that is relevant.
Just my thoughts take them as you will. "People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face
hmm... try remove("C:\\YourFile");
I forgot which one to include.![](wink.gif)
I forgot which one to include.
![](wink.gif)
"after many years of singularity, i'm still searching on the event horizon"
Thanks very much that should do nicely
Just my thoughts take them as you will. "People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face
For a more standard, cross-platform solution, use unlink(). It works under UNIX as well as DOS/Windows, and probably on other platforms as well.
Under true multiuser systems such as UNIX, a file may possess hard and soft links to itself. Unlink therefore removes one of these links, and when there is only one link left (the file itself), it removes the file.
On MS platforms, of course, it just removes the file right away.
---
Those who can do nothing criticize; those who can, critique.
Under true multiuser systems such as UNIX, a file may possess hard and soft links to itself. Unlink therefore removes one of these links, and when there is only one link left (the file itself), it removes the file.
On MS platforms, of course, it just removes the file right away.
---
Those who can do nothing criticize; those who can, critique.
Wrong, _unlink() is non-standard, but remove() is. Use remove. ![](wink.gif)
int _unlink( const char *filename ); // Notice the ''_''
![](wink.gif)
int _unlink( const char *filename ); // Notice the ''_''
quote:
Original post by DerekSaw
hmm... try remove("C:\\YourFile");
That requires the C Runtime library; IMO it would be better to use DeleteFile() as it is implemented in the kernel... unless you really do need cross-platform support.
"All you need to do to learn circular logic is learn circular logic"
"All you need to do to learn circular logic is learn circular logic"
Hes not looking for cross platform support hes using MFC ffs
Edited by - jumble on May 22, 2001 2:03:34 PM
Edited by - jumble on May 22, 2001 2:03:34 PM
jumble-----------
No matter how unstandard he does it... C:\\whatever automatically makes it not able to be crossplatform....
-----------------------------
A wise man once said "A person with half a clue is more dangerous than a person with or without one."
The Micro$haft BSOD T-Shirt
-----------------------------
A wise man once said "A person with half a clue is more dangerous than a person with or without one."
The Micro$haft BSOD T-Shirt
-----------------------------A wise man once said "A person with half a clue is more dangerous than a person with or without one."The Micro$haft BSOD T-Shirt
quote:
Original post by ImmaGNUman
No matter how unstandard he does it... C:\\whatever automatically makes it not able to be crossplatform....
Well, there is DOS... I believe that would truly and technically qualify as a different platform. It''s a platform that wouldn''t support DeleteFile at least, but would support "C:\\whatever". Of course "cross-platform" may refer to ALL platforms and not just more than one platform.
"All you need to do to learn circular logic is learn circular logic"
"All you need to do to learn circular logic is learn circular logic"
quote:
Original post by Silent
Wrong, _unlink() is non-standard, but remove() is. Use remove.
int _unlink( const char *filename ); // Notice the ''_''
My bad. unlink() is POSIX.1 which remove() is ANSI C, which makes remove() more standard.
I''ve been stuck in UNIX-land too long...
---
Those who can do nothing criticize; those who can, critique.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement