NO!
What happens if you can't "deal" with the file..say because the exception
was OutOfMemory (not what you thought it was going to be eh?) you should
still do what you can to close the file. Also, what happens in your
"dealing" with the exception that you decide to throw it...your close call
will never get called. The point of finally is that you are [almost]
guaranteed that the code will get called. Putting your cleanup AFTER the
try/catch doesn't provide a guarantee. Here's another case....your catch
code generates an exception...your cleanup will never get called.
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Henri" <> wrote in message
news:...
> This question is applicable to all the languages, but could someone
provide
> me with an code example where FINALLY is really necessary.
> FINALLY is often used for this kind of code:
>
> Try
> ....
> open a file
> read some date
> ....
> Catch
> ... dealing with the file error ....
> Finally
> close the file
> End Try
>
> But wouldn't the following (without FINALLY) work as well?
>
> Try
> ....
> open a file
> read some date
> ....
> Catch
> ... dealing with the file error ....
> End Try
> close the file
>
> Please tell me what I'm missing.
> Thanks
> Henri
>
>
>