delete a file locked by another process in C#
File.Delete(file);
not working gives error
i have to delete forcefully delete it
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Kapil SharmaPosted Feb 25, 2016, 6:09 AM
VulpesPosted Jul 24, 2013, 6:17 AM
As I said in the previous (deleted) thread, you will have to kill the other process to release the file handle.
You can either do this from the Task Manager, or you can use code similar to this:
using System.Diagnostics;
// ...
File.Delete should then work.