Search code examples
java.netbase-class-library

Is there equivalent to java's File.deleteOnExit() in .NET BCL?


Probably I could make an application domain and hook to DomainUnload event, but I'd like to do that on primary app domain.


Solution

  • There is no analogue in .net :(

    You've got the right idea, you'll need to explicitly delete it.

    // Delete the previously created file.
    File.Delete(filepath);