Option Strict On
Option Explicit On
Imports System
Imports System.IO
Module Module1
Sub Main()
Dim streamreader As StreamReader = Nothing
Try
streamreader = New StreamReader(“D:\automation youtube\data.txt”)
Console.WriteLine(StreamReader.ReadToEnd)
Catch filenotfound As FileNotFoundException
Console.WriteLine(“Please check if the file {0} exists”, filenotfound.FileName)
Console.WriteLine()
Console.WriteLine()
Console.WriteLine(filenotfound.StackTrace)
Catch ex As Exception
Console.WriteLine(ex.Message)
Console.WriteLine()
Console.WriteLine()
Console.WriteLine(ex.StackTrace)
Finally
If IsNothing(streamreader) Then
Else
Console.WriteLine(“finally it’s closing”)
streamreader.Close()
End If
End Try
Console.ReadLine()
End Sub
End Module
Leave a comment