I tried to delete a file in the system using function remove()(fstream.h).
and that file is presend in some other location in the computer.
So I tried using chdir to change directory But it isn't working.
This is the foll program.Help me out please.
#include<dir.h>
#include<stdio.h>
#include<fstream.h>
void main()
{
chdir("D:\\");
remove("BOON.DAT");
if(!"BOON.DAT")
cout<<"File removal sucessful";
else
cout<<"Unable to remove file";
}
First, please use [code][/code] tags around your source codes. Second, remove() is part of stdio.h not fstream.h. Third, that's not how you check if your program deleted the files. Fourth, you could probably simply use remove("D:\\BOON.DAT"); without chdir().
If you're using a limited user account in Windows and not the Administrator account, forget about deleting files you do not control such as system files. Your programs do not have more rights than you do.