On our site, we use global.asax's Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) to catch pretty much all errors thrown. Right now, this sub sends an email with error details. We wish it to stay that way, that is, we don't wish to start using lots of try/catch blocks. Errors, when they occur, have to be studied and fixed so they don't happen again.
However, there are a couple pages where the user can upload a text file, which is then imported into the DB. When an error occurs, the uploaded file becomes locked and can't be moved/deleted until IIS decides to release it (not sure how long that takes, but it's too long).
We can resume the procedure in 3 steps:
1- Open the file
2- Read the file and use those values
3- Close the file
When an error occurs on step 2, the file is then locked. So, is there any way for global.asax's sub to close the file?