Imagine if some other exception occurred that you haven't handled, e.g. an ArgumentOutOfRangeException
, or if you want to rethrow the exception or throw a wrapped exception from your catch block:
The first block would ensure that the file is closed regardless of whether or not an exception occurred.
The second block would only close the file if either no exception occurred or an
IOException
occurred. It does not handle any other cases.