0

I have a project in mind, but there is a section that I don't know how to do. I'm using Python version 3.6 and windows 10. For example we have a file name of "example.txt" I want to prevent the name and its content of this file from being changed.

I did research on this topic, but I could not reach any research. Can we prevent the file's name (including its extension) from changing or its contents?To realize this, I think it is necessary to start as an administrator.

Thanks.

Utku
  • 31
  • 5

1 Answers1

1

It is possible to stop another program from editing a file by locking it in python.

There is a module that does this called filelock. Take a look at the source code to see how it is done.

It is also worth noting that more advanced ransomware will try to stop processes so they can encrypt files, so this might not work in all cases.

KyleL
  • 855
  • 6
  • 24
  • This question has more details too https://stackoverflow.com/questions/489861/locking-a-file-in-python – KyleL Jun 22 '20 at 18:33