How to overwrite a file that is used by another process?
I know which process is locking it, its a .net host instance, but I still want to overwrite my .log file (i want to clear it, when i press a button).
I keep getting
System.IO.IOException: The process cannot access the file
9 Replies
-wait till you CAN access
-kill the process
else out of luck
im looking for a way to force it
You can't.
I googled "log4net reset logs file" did show some interesting results, i will continue there if you cant help
well there are a couple of tools which help you force free filehandles(sysinternals provides something).. but you should just fix your code..
this will surely end well
@Erky all the ways you could force this would probably crash (or at least cause an exception in) the writing process.
maybe forcing it is the wrong idea, but rather just investigating nuget package, log4net, client.log and edit configuration or something
In Unix yes, in Windows no. Heh.