I have a console application. If something goes wrong i need to call Environment.Exit(); to close my app. I need to disconnect and close some files before my application exit.
In Java i can implement Runtime.getRuntime().addShutdownHook(). Can someone help me?