Python accessing hidden zip file using ZipFile permission error

59 Views Asked by At

I am creating a "secure file manager" which just consists of a hidden zip file and a python script that asks for a password to manage the zip file externally.

I am getting an error when I try to remove a file like

from zipfile import ZipFile
from ruamel.std.zipfile import delete_from_zip_file

zip_file = ZipFile("secret.zip")

file_list = [file.filename for file in zip_file.filelist]

print(file_list)
if "test.txt" in file_list:
    delete_from_zip_file("secret.zip", "test.txt")

I get the error

PermissionError: [Errno 13] Permission denied: 'secret.zip'

Although when I make the zip file not hidden it works completely fine.

Any reason this is happening and how can I fix it so it works while being hidden?

The delete_from_zip_file("secret.zip", "test.txt") is whats causing the error but I'm unsure of another way to remove a file easily

1

There are 1 best solutions below

5
simbullar On

I am not totally sure, but you can try opening the code as administrator. Sorry if that did not help.