Should Dispose() or Finalize() be used to delete temporary files?

后端 未结 8 1249
隐瞒了意图╮
隐瞒了意图╮ 2021-02-04 02:35

I have a class that makes use of temporary files (Path.GetTempFileName()) while it is active. I want to make sure these files do not remain on the user\'s hard driv

8条回答
  •  悲哀的现实
    2021-02-04 03:11

    You should definitely use Dispose to clean up resources, but make sure you implement the IDisposable interface. You don't want to just add a method named Dispose.

提交回复
热议问题