Open txt file when button is pressed in VB.NET

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

Please note that I am using VB.NET 2010.

+4
source share
2 answers
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 
+16
source

Here is a simple example:

  Public Class OpenTextFile Private Sub OpenTextFile_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub OpenBUT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenBUT.Click 'OpenBUT_Click the text file Process.Start("C:\File Name.txt") End Sub End Class 
+3
source

Source: https://habr.com/ru/post/1502380/