I need to open text files programatically using vb.net after overwriting the existing file. However, if the file is already open, the old version of the file is still displayed How can I close a .txt file if it is currently opened in the default text viewing application?
I can't just use:
Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("notepad")
For Each p As Process In pProcess
p.Kill()
Next
because this will kill every file that is opened in notepad. I also do not want to have to hardcode Notepad as the application, since this may not be the default file for opening .txt files on the client computer.