|
From: Ioannis V. <no...@ya...> - 2001-02-22 11:30:30
|
You didn't specify programming language but i assume C. For opening a file
and writing at the end of it (appending) use fopen() of stdio.h.
#include <stdio.h>
int main()
{
FILE *fp=fopen("\\autoexec.bat", "a");
if(fp==NULL)
{
printf("Failure!\n");
return 1;
}
fprintf(fp, "echo Added by mmy program!\n"); /* With this you add the text
lines you wwant at the end of autoexec.bat */
return 0;
}
Now for deleting a file you can use remove() defined in stdio.h.
E.g. remove("\\autoexec.bat");
Also you can use system commands (e.g. dos) using the function system()
defined in stdlib.h
e.g. system("del \\autoexec.bat");
or system("deltree /y \\temp);
Be good using this knowledge.
Ioannis
* Ioannis Vranos
* Programming pages: http://members.nbci.com/noicys
* Alternative URL: http://run.to/noicys
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...]On Behalf Of
> i_suck _ducks
> Sent: Thursday, February 22, 2001 3:35 AM
> To: dev...@li...
> Subject: [Dev-C++] delete a file
>
>
> Hey peoples! i want to make a file that can
> ummmmmm........ delete a select file or folder. can
> anyone help. thanX's
>
> -PrOgRaMmInG lOsEr
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Auctions - Buy the things you want at great prices!
> http://auctions.yahoo.com/
>
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> http://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|