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

Getting access denied... O_o

Started by diamondpumpkin, 16 March 2016 - 01:29 AM
diamondpumpkin #1
Posted 16 March 2016 - 02:29 AM
I'm trying to move a file from my disk drive to my computer, and I'm getting access denied… I do have another computer next to it, but when it's off it does the same thing.

Code:
http://imgur.com/svWE28a

Line 9 is the one giving the error.
Edited on 16 March 2016 - 01:32 AM
Bomb Bloke #2
Posted 16 March 2016 - 02:52 AM
Don't neglect to close your file handles (eg "h") when you're done with them. You may also have a handle persisting on the local "temp" file, in which case rebooting the computer should clear it.
diamondpumpkin #3
Posted 16 March 2016 - 02:58 AM
Don't neglect to close your file handles (eg "h") when you're done with them. You may also have a handle persisting on the local "temp" file, in which case rebooting the computer should clear it.

I've restarted multiple times, and I've added the close to the one you suggested.
Bomb Bloke #4
Posted 16 March 2016 - 08:53 AM
And should I assume you're getting the same error on the same line?

Alright, what's fs.getFreeSpace("") returning?
diamondpumpkin #5
Posted 16 March 2016 - 06:27 PM
And should I assume you're getting the same error on the same line?

Alright, what's fs.getFreeSpace("") returning?
Yes, it's still access denied on line 9.

The space is:
997976

Edit: Something that may be worth saying, when I run the program, it copies the file onto the computer BUT doesn't move it from the disk to the computer. So, basically, it's copy with an error.
Edited on 16 March 2016 - 05:32 PM
Mr_Programmer #6
Posted 16 March 2016 - 07:08 PM
And should I assume you're getting the same error on the same line?

Alright, what's fs.getFreeSpace("") returning?
Yes, it's still access denied on line 9.

The space is:
997976

Edit: Something that may be worth saying, when I run the program, it copies the file onto the computer BUT doesn't move it from the disk to the computer. So, basically, it's copy with an error.
To close your file, which you need to do if moving or deleting the file thats open you would do this
 local h = fs.open( AlocatedFile, "r")
local j = h.readLine() --# you dont have to declare a line number

h.close() --# this will close the file allowing you to do what you want to do IE: move the file

Always remeber to close the file after you have read the lines you need or you will always get "Access Denined"

Hope this works :P/>
Dragon53535 #7
Posted 16 March 2016 - 07:09 PM
Don't neglect to close your file handles (eg "h") when you're done with them. You may also have a handle persisting on the local "temp" file, in which case rebooting the computer should clear it.
To close your file, which you need to do if moving or deleting the file thats open you would do this
 local h = fs.open( AlocatedFile, "r")
local j = h.readLine() --# you dont have to declare a line number

h.close() --# this will close the file allowing you to do what you want to do IE: move the file

Always remeber to close the file after you have read the lines you need or you will always get "Access Denined"

Hope this works :P/>
A bit late. Of course he might of done it wrong, but still a bit late :P/>
Edited on 16 March 2016 - 06:10 PM
Mr_Programmer #8
Posted 16 March 2016 - 07:11 PM
Don't neglect to close your file handles (eg "h") when you're done with them. You may also have a handle persisting on the local "temp" file, in which case rebooting the computer should clear it.
To close your file, which you need to do if moving or deleting the file thats open you would do this
 local h = fs.open( AlocatedFile, "r")
local j = h.readLine() --# you dont have to declare a line number

h.close() --# this will close the file allowing you to do what you want to do IE: move the file

Always remeber to close the file after you have read the lines you need or you will always get "Access Denined"

Hope this works :P/>
A bit late
I mean reboting the computer ever time to solve the issue isnt a effective way of sorting it out, hence why i posted what i posted
diamondpumpkin #9
Posted 16 March 2016 - 08:03 PM
To close your file, which you need to do if moving or deleting the file thats open you would do this
 local h = fs.open( AlocatedFile, "r")
local j = h.readLine() --# you dont have to declare a line number

h.close() --# this will close the file allowing you to do what you want to do IE: move the file

Always remeber to close the file after you have read the lines you need or you will always get "Access Denined"

Hope this works :P/>

I am well aware of this, I've closed it when Bomb Bloke said something. However, it's still not working.
Edited on 16 March 2016 - 07:04 PM
Mr_Programmer #10
Posted 16 March 2016 - 08:09 PM
I am well aware of this, I've closed it when Bomb Bloke said something. However, it's still not working.
and it is still syaing the is a error on line 9, i have read thought the code mulitple times and cant seam to see what the problem is at all!

Could you post the rest of your code or upload it to pastebin and give the link just so i can read though everything?
diamondpumpkin #11
Posted 16 March 2016 - 08:12 PM
I am well aware of this, I've closed it when Bomb Bloke said something. However, it's still not working.
and it is still syaing the is a error on line 9, i have read thought the code mulitple times and cant seam to see what the problem is at all!

Could you post the rest of your code or upload it to pastebin and give the link just so i can read though everything?

I'm new to Lua/computercraft could you tell me how to upload it to pastebin? Or would I have to type it?

Edit: Figured it out on my own, rather easy.
Here is the pastebin:
http://pastebin.com/aPzvAFsR
here is the one that's getting the error:
http://pastebin.com/UwG9rMhz
Line 18

If you're wondering how I got from line 9 to 18, I was messing around with the code a little and managed to sneak the file into the computer I was having trouble with first by coping it and attempting to delete the file after it was copied with another computer. The second part failed.

Edit: I believe I found the problem… Since I was terminating the startup, it didn't have a chance to close the file, thus giving the problem. I'm going to double check before I say problem solved.

Edit once more: Yes, terminating the program before it closed the file threw the error access denied. Restarting worked, just that the program I terminated was startup…
Edited on 16 March 2016 - 09:20 PM