I am using streamreader to read from a file upon startup, but if this file doesnt exist, or is empty the program crashes at startup.
This file is a log file, and is created by the program at a later point.
I could solve the problem by putting the declaration for the streamreader in an if statement which checks if file exists, but i am old fashioned, and this just seems wrong.
So what i am basically asking it is whether i can stop it from crashing if the file doesnt exist. Heres is the declaration line
Thanks.
This file is a log file, and is created by the program at a later point.
I could solve the problem by putting the declaration for the streamreader in an if statement which checks if file exists, but i am old fashioned, and this just seems wrong.
So what i am basically asking it is whether i can stop it from crashing if the file doesnt exist. Heres is the declaration line
Code:
Dim sr As New StreamReader(LogPath & ".hist")
Thanks.