This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
grand_mind1's profile picture

Delete:9: Access Denied

Started by grand_mind1, 12 August 2013 - 05:59 PM
grand_mind1 #1
Posted 12 August 2013 - 07:59 PM
So I was playing around with the fs api trying to make a program with savable settings. I made this small program while testing:

h = fs.open("settings","w")
h.write("--Testing comment")
h.close()
h = fs.open("settings","a")
h.writeLine("Add below the comment")
h.writeLine("Hello")
h.writeLine("Hi")
h.writeLine("Hey")
h.close()
I was just messing around so none of this really does anything useful. So now the file name settings looks something like this:

--Testing comment
Hello
Hi
Hey
I wanted to change some stuff so I tried to delete settings but I got this error:

Delete:9: Access denied
I know you get this when trying to delete like one of the main files but I don't see why it wouldn't let me delete it here.
If someone could explain why this happened and how to fix it, that would be great.
Help is appreciated!
Thanks! :D/>
Grim Reaper #2
Posted 12 August 2013 - 09:28 PM
Try restarting the computer in game or try even restarting Minecraft altogether.

I tested the code that you provided and was unable to recreate this error, but usually problems with deleting stem from handles on the file that you're trying to delete which haven't been closed. However, your code appears to be closing the handle each time that you use it.
grand_mind1 #3
Posted 12 August 2013 - 09:38 PM
That's odd. After restarting minecraft it seemed to fix itself. I don't know what happened.
Thanks!
immibis #4
Posted 14 August 2013 - 04:06 AM
Usually, "access denied" when deleting means you forgot to close the file. It could also mean something outside Minecraft has the file open (e.g. a virus scanner)