08-04-2013, 08:28 AM
Hello everyone
I have two questions that are bothering me now for a long time but can't find any answers to it. These questions are about Exceptions in VB.NET.
- I know what the Try...Catch block does, it catches any errors, but how far do you have to go? For example you want to open a file but it is
possible that the file doesn't exist then you use the Try...Catch, I know that. Is it also needed for example changing the text of a textbox or editing items in a treeview...
- The second question is about the Finally block. Let's say we've downloaded a file but there occurres an error during the downloading process, the Catch block catches the error... and then I want to remove the downloaded file if it exists. Then there is a possibility that the file doesn't exist so if I write
in the Finally block it throws a second exception right? or does VB.NET take care of that automatically?
Thanks, Brecht
I have two questions that are bothering me now for a long time but can't find any answers to it. These questions are about Exceptions in VB.NET.
- I know what the Try...Catch block does, it catches any errors, but how far do you have to go? For example you want to open a file but it is
possible that the file doesn't exist then you use the Try...Catch, I know that. Is it also needed for example changing the text of a textbox or editing items in a treeview...
- The second question is about the Finally block. Let's say we've downloaded a file but there occurres an error during the downloading process, the Catch block catches the error... and then I want to remove the downloaded file if it exists. Then there is a possibility that the file doesn't exist so if I write
Code:
My.Computer.DeleteFile(pathFile)
Thanks, Brecht