I've been receiving this error for quite some time on a few assignments.
Message=[Errno 2] No such file or directory: 'frankenstein.txt'
Source=C:\Users\richy\OneDrive\Documents\Python Scripts\CIS 521\CIS 521\CIS 521\Homework8\homework8.py
StackTrace:
File "C:\Users\richy\OneDrive\Documents\Python Scripts\CIS 521\CIS 521\CIS 521\Homework8\homework8.py", line 171, in create_ngram_model
with open(path, "r") as f:
File "C:\Users\richy\OneDrive\Documents\Python Scripts\CIS 521\CIS 521\CIS 521\Homework8\Test.py", line 72, in <module>
m = create_ngram_model(1, "frankenstein.txt"); m.random_text(15)
The file is within the solution explorer project and the build action is content. I've found a workaround in which I create string variable of the path but I would like to understand why it cannot locate the file and how to correct this issue.
test_text = os.path.join(os.path.dirname(__file__), 'frankenstein.txt')