Rob,
I think that if you change the scope of the try...catch you will find that
you can accomplish what you are looking for. Take the following pseudo code
for example...
Try
For x = 1 to 100
' Do something that causes an error occasionally.
Next
Catch Exception
Using the preceding exception handling you cannot return to the loop to
continue. But if you simply change it to:
For x = 1 to 100
Try
' Do something that causes an error occasionally.
Catch Exception
Next
You're code can continue to work on the loop. When you catch exceptions you
want to keep it to the smallest scope possible and want to catch the most
specific exception possible. By this I mean, assume that you are using
File.Copy to copy a file. Looking in the MSDN documentation you can see that
it can throw 8 different exception types. You may be tempted to catch
System.Exception just to have one catch block but with a little forethought
you do not need to worry about all 8 of them. You can check the arguments
that you pass in before to make sure that they are valid and eliminate the
possibility of it throwing ArgumentException, ArgumentNullException,
DirectoryNotFoundException, FileNotFoundException, and NotSupportedOption.
If you have checked for permissions or used code access security to specify
your permissions you can avoid the UnuathorizedAccessException. Thus, you
would just need to catch the IOException which you can not really plan around
since you cannot know ahead of time if your hard drive is going to crash.
I hope this long winded answer is close to what you were looking for.
Michael