[RESOLVED] Run Time Error 70, premission denied with ResToFile? Why is this!?
Here is the code i am using for put a resource(music) to a file.
Code:
Public Sub ResToFile(FileName As String, ResID As Variant, ResType As Variant, Optional overwrite As Boolean = True)
Dim Buffer() As Byte
Dim Filenum As Integer
If Dir(FileName) <> Empty Then 'Check if output file already exists
If overwrite Then Kill FileName Else Err.Raise 58
End If
Buffer = LoadResData(ResID, ResType) 'Load the resource into a byte array
Filenum = FreeFile
Open FileName For Binary Access Write As Filenum
Put Filenum, , Buffer 'Write the entire array into the file
Close Filenum
End Sub
I have run it like 4 times, and it has worked before. Idk why its saying this now. It highlighted the text above that is in blue, and i checked the path and there was a file there.... Why is it giving me this error, and how can i fix it?
EDIT: XD I got it. Added Kill then the only file that was giving me that problem. =P
Re: [RESOLVED] Run Time Error 70, premission denied with ResToFile? Why is this!?
You should note that Kill will not be able to delete a file if it has the read only or hidden attributes set, and if the file is protected (Vista/W7) that will require admin rights to delete. Maybe you should error-check to see if delete was successful.
Re: [RESOLVED] Run Time Error 70, premission denied with ResToFile? Why is this!?
What about it being an archive? because i have XP OS.
Re: [RESOLVED] Run Time Error 70, premission denied with ResToFile? Why is this!?
I think it can delete the archive fine. But in any case, you can use the SetAttr function to set it to vbNormal which will remove other attributes so it can be deleted.
Re: [RESOLVED] Run Time Error 70, premission denied with ResToFile? Why is this!?
...How would you do that?
Re: [RESOLVED] Run Time Error 70, premission denied with ResToFile? Why is this!?
Like I said, SetAttr. It's an internal VB function, just set the file you want to delete to vbNormal with it, then do a Kill.
Re: [RESOLVED] Run Time Error 70, premission denied with ResToFile? Why is this!?