How to handle exceptions for bad file/filenotfound,etc.

Oct 26, 2010 at 8:51 PM

I can only seem to get file not found exception to work. I'd like to have my code report if it's a bad file, as well as any generic exceptions. Once test I did is to create a blank or bogus zip file and try to extract it.  My app will open then close as soon as it tries to read the zip file and does not display an exception.

Any ideas?


Oct 27, 2010 at 1:13 AM

Show your code, especially the try...catch statements where you handle exceptions.

Keep in mind that ZipFile.Read() can throw System.IOException, among other exceptions.  Said another way, not all exceptions thrown by ZipFile.Read() are of type Ionic.Zip.ZipException.  This is documented in the reference page for ZipFile.Read().   One implication: If you have a catch clause that specifies Ionic.Zip.ZipException, you will not catch these other exceptions, and your program will just exit.