Skip to main content
The 2024 Developer Survey results are live! See the results

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • I am able to catch the modified event by os.path.getmtime(filename).Actually I want to delete the file as soon as it is closed(both either file is close from a tab of notepad++ or normal notepad). User can modify a file many times before closing a file.
    – imp
    Commented Mar 25, 2014 at 13:38
  • @imp I think all answers here are wrong because they try to answer the question on a close event on file system level whereas your comment suggests you want the close event on application level‽ Closing a file on file system level is something different than closing a document in an application unless the application really opens the file at the beginning and closes it at the end. Which is quite unlikely in the case of text editors. When opening a document they open the file, read the content, and close it. Closing the document in the editor then generates no event on file system level!
    – BlackJack
    Commented Jul 11, 2019 at 8:31