class throwException { System.IO.FileStream logFile = null; if (!this.logFile.CanWrite) //this if can be your condition for files correct format { throw new System.InvalidOperationException("your error message"); } }
try { //try to do something } catch (Exception ex) { //if it fails, the code goes here, and ex has a bunch of information about the error } finally { //this code runs after the error is thown, it is good for closing files and freeing up resources that you have used. }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)