Files
TrainingAdvancedTechniques/Exceptionhandling/Program.cs

33 lines
755 B
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Exceptionhandling
{
class Program
{
static void Main(string[] args)
{
StreamReader streamreader = null;
try
{
streamreader = new StreamReader(@"c:\file.zip");
var content = streamreader.ReadToEnd();
}
catch (Exception ex)
{
Console.WriteLine("Sorry, an unexpected error occured. :" + ex.Message);
}
finally
{
if (streamreader != null)
streamreader.Dispose();
}
}
}
}