Open a txt file when a button clicked in VB.NET

User7291 picture User7291 · Sep 16, 2013 · Viewed 62.9k times · Source

I have a log file in my project. This file is a text file (.txt). Is there a way to open this file when a button clicked without using the OpenFileDialog tool?

Note that I'm using VB.NET 2010.

Answer

VB.NET LEARNER picture VB.NET LEARNER · Sep 16, 2013
Dim FILE_NAME As String = "C:\FileName.txt"

If System.IO.File.Exists(FILE_NAME) = True Then
    Process.Start(FILE_NAME)
Else
    MsgBox("File Does Not Exist")
End If