Invoke Code - Access to the path '[path].zip' is denied

Hello,

I’m trying to delete a .Zip file from my downloads folder. I used the activity Delete, but was given an access issue error. I discovered the .zip property is Read Only and it must be changed before the activity works. The error was: Access to the path '[path].zip' is denied.

I 'm using Invoke Code to change the attribute of the file to remove ‘Read Only’. This code works perfectly when in Debug mode, but once I run the process full speed, the Invoke Code doesn’t work.

I added delays in front and behind the invoke code, and it doesnt seem to help.
Code to remove ‘Read Only’:

Try
System.IO.File.SetAttributes(filePath, System.IO.File.GetAttributes(filePath) Xor FileAttributes.ReadOnly)

Catch ex As exception
out_exception=ex

End Try

Any ideas on why Invoke code doesn’t work when running full speed? My goal is to delete the .zip and this was my work around.

1 Like

I ended up not trying to set one attribute for the file, and rather set all the file attributes back to ‘Normal’.

Hope this helps others in the future:

Try
System.IO.File.SetAttributes(filePath, System.IO.FileAttributes.Normal)

Catch ex As exception
out_exception=ex

End Try

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.