2
Answers

Checking for Open Text File in Notepad, and Closing it

I wonder if anyone might be able to resolve the following issue: I have a text file, which I write to using a StreamWriter. I want to be able to append to the file, but beforehand I must ensure that the file is closed. I have tried using System.Threading.Mutex(), System.Diagnostics.Process.GetCurrentProcess(), and System.Diagnostics.Process.GetProcessesByName(). But with no success. I think my problem mainly exists with either detecting whether a file is open (i.e. file locked), or the specific file is open, as opposed to the application (Notepad) which it runs in. Any assistance would be greatly appreciated. Thanks
Answers (2)