New scenario YouTubeexception etc

This commit is contained in:
2019-01-09 23:23:56 +01:00
parent f455ac39ff
commit 5f7139c481
5 changed files with 62 additions and 9 deletions

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
@ -12,21 +11,18 @@ namespace Exceptionhandling
static void Main(string[] args)
{
StreamReader streamreader = null;
try
{
streamreader = new StreamReader(@"c:\file.zip");
var content = streamreader.ReadToEnd();
using(var 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();
}
}
}
}