I'm updating an existing page that makes use of the asp.net wizard control. I'm adding an optional step that will allow the user to upload a file.
I'm already past the first issue: I don't actually want to use the file until the wizard's finished button is selected, but I have to upload the file from the new step rather than the final step. That's no big deal. I just have an upload button on the page next to the control so you upload it in place. At this point I save it to App_Data folder and change the appearance of the wizard step to show there's an uploaded file (with an option to change it). There's also a custom validator control to make sure you finish that before moving on to the next step, but that's extra information.
The next issue is that I don't need or want these files around any more after I complete processing for the finish step, or if the user never gets that far. I can clean up the file okay after the finish step, or if the user decides to change to a new file, so I've solved most of this as well.
My problem is that I want a better way to clean up files when the user abandons the wizard after passing the new step but before clicking 'Finish'. I could do it in a batch app or on application start, but I'd rather keep the code all contained to the page with the wizard. Any ideas?