README.md
December 4, 2022 ยท View on GitHub
Description
As .Net does Not include App object as in VB here is a solution for App.Path and App.ExeName
More Info
Just add this class in your application and use it
App.Path and App.EXEName
| Submitted On | |
| By | Pankaj Nagar |
| Level | Beginner |
| User Rating | 4.3 (30 globes from 7 users) |
| Compatibility | VB.NET |
| Category | System Services/ Functions |
| World | .Net (C#, VB.net) |
| Archive File |
Source Code
Option Explicit
Option Strict
Imports System
Imports System.IO
Class ThisApp
Private mAppPath As String
Private mExeName As String
Public ReadOnly Property AppPath() As String
Get
Return mAppPath
End Get
End Property
Public ReadOnly Property ExeName() As String
Get
Return mExeName
End Get
End Property
Public Sub New()
Dim p As Path
Try
mAppPath = System.Reflection.Assembly.GetExecutingAssembly.Location
mExeName = Dir(mAppPath)
mAppPath = p.GetFullPath((Left(mAppPath, (Len(mAppPath) - Len(mExeName)))))
Catch
MsgBox(Err.Description, MsgBoxStyle.Critical, "Error!")
End Try
End Sub
End Class
Module modMain
Sub Main()
Dim MyApp As ThisApp = New ThisApp()
MsgBox(MyApp.AppPath, MsgBoxStyle.Information, "App Path")
MsgBox(MyApp.ExeName, MsgBoxStyle.Information, "Exe Name")
End Sub
End Module