[Solved] Try-Catch-Finally c# in Console [closed]

Other than what people already said about the try…catch…finally block, I believe what you’re looking for is

try {
    file = new FileStream("example.txt", FileMode.Open);
catch (Exception ex) {

But you need to add reference to System.Windows.Forms in your project and add the using statement to your class

using System.Windows.Forms;

Or, if you just want to display the message in the console, you can use


and forget the reference

solved Try-Catch-Finally c# in Console [closed]