VB icon

App.Path & App.EXEName

Email
Submitted on: 1/1/2015 12:05:00 AM
By: Pankaj Nagar (from psc cd)  
Level: Beginner
User Rating: By 7 Users
Compatibility: VB.NET
Views: 2448
 
     As .Net does Not include App object as in VB here is a solution for App.Path and App.ExeName
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: App.Path & App.EXEName
// Description:As .Net does Not include App object as in VB here is a solution for App.Path and App.ExeName
// By: Pankaj Nagar (from psc cd)
//
// Returns:App.Path and App.EXEName
//
// Assumes:Just add this class in your application and use it
//**************************************

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


Other 8 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.