New scenario YouTubeexception etc
This commit is contained in:
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user