What are a good way to ensure that a tempfile is deleted if my application closes or crashes? Ideally I would like to obtain a tempfile, use it and then forget about it.
You could launch a thread on startup that will delete files that exist when they "shouldn't" to recover from your crash.