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

Apr 14, 2019 at 8:27am
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 Apr 14, 2019 at 9:39am
Apr 14, 2019 at 11:07am
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.
Apr 14, 2019 at 3:23pm
...
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 Apr 14, 2019 at 3:33pm
Apr 14, 2019 at 5:34pm
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!
Apr 14, 2019 at 9:00pm
thank you guys :)
Topic archived. No new replies allowed.