Running remove() gets permission denied error...
OS: Vista
Compiler: Visual Express 2008
I'm programming a game using C code where I have to rewrite data in a text file. My problem is deleting a file using the remove() function.
So what want I do is create a temp file, write the new data in it, then copy the other data from the other file into the temp file, and then finally delete the old file and rename the temp to the old file.
I've made sure the files are closed when I call the functions remove() and rename() and I get the permission denied error with remove() and of course rename() won't work because the old file still exists.
I'm running VE as administrator, I've disabled the UAC, I've made sure the read-only boxes are unchecked, I've placed all the files in my user directory also to run it, the remove() function returns -1 which perror() retrieves "permission denied". The data going into the temp file is fine (if it's relevant). All my files have full control permissions for me and Administrator.
I've searched all over and can't find anything on the fix. I started to believe it was because Vista keeps placing the text files in read only but the file properties explicitely has no check mark under the read only box.
Is there a setting in the compiler I'm overlooking? Or is something in Vista?
[edit: line 6, word 3: added 'want']