I’m having trouble with file close() not working as expected.
If I run this sample code:
import tempfile import commands import os froot = system.tag.read("[Client]ctAppRootDirectory").value ftemp = froot + "delete_me.txt" ft = open(ftemp, "w+") ft.write("File written to.") ft.close() try: os.remove(ftemp) except: system.gui.messageBox("Couldn't remove " + ftemp + ".")
- The “delete_me.txt” file is created.
- The “Couldn’t remove delete_me.txt.” message pops up.
- I can’t delete the file with Windows explorer. I get “File in Use” messagebox with message “The action can’t be completed because the file is open in Java™ Platform SE binary. Close the program and try again.”
- Oddly, I can edit the file in Notepad++ and save it.
- If I quit the Ignition! Designer I can delete the file.
- If I run the code again it will overwrite my edit.
Any ideas what’s happening in the engine compartment?