How can I delete a file that is in use by another process?

前端 未结 6 571
野性不改
野性不改 2020-12-10 05:34

When I try to delete a file occurs the following exception:

The process cannot access the file \'\' because it is being used by another process.<

6条回答
  •  有刺的猬
    2020-12-10 06:27

    slightly off topic: But it seems from your code that you are trying to delete all files of your folder. Well instead of deleting them one by one we have another method Directory.Delete(path, True) which will delete the directory as contained in the string named path. Then you may recreate the directory if you want. But your problem may persist here too.

提交回复
热议问题