remove() function's not working (perror:permission denied)

case 3:
cout << "Silme işlemini nasıl yapmak istersiniz?\n1-Ürün ID\n2-Ürün İsmi\n";
cout << "İŞLEM NO: "; cin >> secim3; cin.ignore();
if(secim3==1){
do{
cout << "Ürün ID: "; cin >> urunID;
id_kontrol=strlen(urunID);
if(id_kontrol!=8) cout << "Lütfen geçerli ID giriniz!\n";
}while(id_kontrol!=8);

fstream dosyaoku("urun_bilgi.txt",ios::in);
while(!dosyaoku.eof()){
getline(dosyaoku,okunan);
eslesme=okunan.substr(0,8);
if(urunID!=eslesme){
fstream yenidosya("yenibilgi.txt",ios::out|ios::app);
yenidosya << okunan << endl;
yenidosya.close();
}
}

dosyaoku.close();
remove("urun_bilgi.txt");
rename("yenibilgi.txt","urun_bilgi.txt");
}

break;
Last edited on
Where is your call to perror?
In other words, how do you know it's permission denied?

Removing a file usually needs write permission on the directory.
...
remove("urun_bilgi.txt");
perror("error: ");
...

perror is here, sorry i forgot.

error image:
https://i.hizliresim.com/k9lEgm.png
(when i try delete other file, it is successfuly done.)
Last edited on
As salem c hinted, all the file manipulation functions require your application to have access rights to do what you are asking.

In other words, it is not a C/C++ problem. Check to see that (1) your user has rights to do things like delete and rename the files you are targeting, and (2) that your application runs with the necessary privileges.

Good luck!
thank you guys :)
Topic archived. No new replies allowed.