I believe some anti-virus softwares will prevent changes to the host file. A windows service might also have a lock on it. Here are some things to try:
- Right click the file and make sure its not Read-Only
- Run N++ as administrator and try to edit it again
- Reboot into safe mode and edit it
- Save it as .changed and use the windows console or python library to copy the file to hosts
- Find which process is using the file and kill it.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Greetings!
I use NPP 7.5.3 x86 and Python Script 1.0.8.0.
notepad.saveAs("D:\t.txt")
gives
However
works as designed.
What could be the root cause for this?
Thank you.
Last edit: Andrey Kazak 2017-12-20
I believe some anti-virus softwares will prevent changes to the host file. A windows service might also have a lock on it. Here are some things to try:
- Right click the file and make sure its not Read-Only
- Run N++ as administrator and try to edit it again
- Reboot into safe mode and edit it
- Save it as .changed and use the windows console or python library to copy the file to hosts
- Find which process is using the file and kill it.
Dear David,
Thank you.
Running N++ as administrator solved the issue.
However I do not see the crucial difference between
notepad.saveAs("D:\t.txt")
and
newFilename = notepad.getCurrentFilename() + ".changed"
Yeah, my intuition would also say that your notepad.saveAs() should work, but it must still require that the hosts file be unlocked.
Have you tried saveAsCopy()? I'm thinking that
notepad.saveAsCopy("D:\t.txt")
should do what you are expecting...