Advertisement
C_Volume2 System Services/ Functions #84761

App.Path & App.EXEName

As .Net does Not include App object as in VB here is a solution for App.Path and App.ExeName

AI

สรุปโดย AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

ซอร์สโค้ด
original-source
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

ความคิดเห็นดั้งเดิม (3)
กู้คืนจาก Wayback Machine