Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open a txt file when a button clicked 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 a button clicked without using the OpenFileDialog tool?

Note that I'm using VB.NET 2010.

like image 749
User7291 Avatar asked Sep 16 '13 10:09

User7291


Video Answer


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
like image 188
VB.NET LEARNER Avatar answered Sep 28 '22 00:09

VB.NET LEARNER


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
like image 35
Mousa Alfhaily Avatar answered Sep 28 '22 01:09

Mousa Alfhaily