Expand my comment. The file is locked if the handle remains open by the application. Word, for example, will open the file, read it in the stream, and save the handle so that other applications cannot delete this file while the user is working on it.
Notepad and other applications just open the file, read the entire stream, and close the file that releases the lock they have. This means that the file is no longer locked and can be edited by another application or even deleted, and Notepad does not take care that it has its own copy in memory.
You can try and hack using Notepad instances and check if the file is open, but ultimately this is not a great idea. If the file is not locked, you should be free to do whatever you want with it.
source share