Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have used system("del temp.txt") to delete a file before.
But now i want to delete a file whose filename is stored in the string variable "fname" and the extensions at "ext1", "ext2" & "ext3". So how to delete the 1 and 3 files with the same name but with 2 different extensions. I want to retain the file with the extension "ext2".

Using system:
char filename[100];
sprintf(cmd,"del %s.ext1 %s.ext3",fname,fname);
system(cmd);
I'm assuming that "del file.ext1 file.ext3" is a valid way to delete two files. If not, you'd just build the "cmd" twice, once for each filename, and run system twice.
Also, you might look up "unlink" in your compiler docs. I believe that some compilers support this for deleting files.Be sure to come back and let us know if our suggestions helped!

![]() |
Computer temp. in VB6
|
Command Button Behaviour-...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |