First off you should never use On Resume Next, as it is bad to ignore errors. Instead use assertion i.e.
This is not good if the file does not exist.
Best to check if the file exists first, this is assertion.Code:IO.File.Delete("Somefile.txt")
For unexpected exceptions you can override the default unhandled exception handler, see attached VS2010 project, compile, run outside of the IDE then inside the IDE. Next look at the error log file created in the app executable folder.Code:Dim fileName As String = "Somefile.txt" . . . If IO.File.Exists(fileName) Then IO.File.Delete(fileName) End If
Bottom line is write tight code, test well and when there is an unexpected error write assertion to trap for this and as a last resort use Try/Catch and never leave the Catch section empty.




Reply With Quote
