-2

I have a some code in C# to delete a file, and sometimes I get the following IOException while I can't find any program using this file.

The process cannot access the file  because it is being used by another process

How can I solve this problem?

I did not find any solution.

  • Please show us your code in order for us to help you further. The error means that something else is using the file so you can't delete it. – Jayme Jan 17 '23 at 07:19

1 Answers1

0

Use Process Monitor to look which process is causing the issue. https://learn.microsoft.com/en-us/sysinternals/downloads/procmon I bet it's your own code that did something before with the file and didn't really finish it.

The incredible Jan
  • 741
  • 10
  • 17