I have a test.log file, and I want to edit that programmatically.
string text = File.ReadAllText("test.log");
text = text.Replace("xxx", "yyy");
File.WriteAllText("test.log", text);
But I receive the error "file is in use by another process."
How can I find the process using this file to kill it?
I used this code Process.GetProcesses()
, but that was a long list without any helpful information. Also, this file generated from a dll
and I don't have access to its code.
I also cannot use a third party program such as lockhunter
or handel.exe
for this purpose.