After changing the Ransomware Protection on windows (GroupPolicy), python has been causing all sorts of weird errors for me. I am not getting filenotfound errors when trying to write to a directory that exists. My snippet is as follows:
import os
print("Does Dir Exist: ",end="")
print(os.path.isdir(test_dir))
print("Test Reading....")
with open(os.path.join(test_dir,"test_read_file.txt"),'r') as outrf:
print(outrf.readlines())
print("Test Writing....")
with open(os.path.join(test_dir,"test_file.txt"),'w') as outwf:
outwf.write("Test Writing to file")
print("Done!")
When I do this, I get the following output:
Does Dir Exist: True
Test Reading....
['test reading']
Test Writing....
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-6-fec57d58c3b2> in <module>
6 print(outrf.readlines())
7 print("Test Writing....")
----> 8 with open(os.path.join(test_dir,"test_file.txt"),'wb') as outwf:
9 outwf.write("Test Writing s;dfhas;dhfadf")
10 print("Done!")
FileNotFoundError: [Errno 2] No such file or directory:...
This works fine without the Ransomware Protection turned on. Is there a way around it?
Verify where the file comes from... Try to put the whole path or add "" before your path "test_file.txt"