ARTICLE

Get Application Startup and Executable Path in VB.NET

Posted by Mahesh Chand Articles | Windows Forms VB.NET April 25, 2010
The code snippet in this article demonstrates how to use Application class static properties to get Windows Forms application startup path, executable path and user data path using VB.NET.
 
Reader Level:

Application Path

CommonPathAppData property returns the path for the application data that is shared among all users. If a path does not exist, the default created path format is Base Path\CompanyName\ProductName\ProductVersion.

UserAppDataPath property returns the path for the application data of a user. If a path does not exist, the default created path format is Base Path\CompanyName\ProductName\ProductVersion.

LocalUserAppDataPath property returns the path for the application data of a local user. If a path does not exist, the default created path format is Base Path\CompanyName\ProductName\ProductVersion.

StartupPath property returns the path for the executable file that started the application, not the path where the application executable is stored.

ExecutablePath property returns the path for the executable file that started the application, including the executable name.

CommonAppDataRegistry property returns the registry key for the application data that is shared among all users.

AllowQuit property returns true if the caller can quit the current application.

The C# code snippet in Listing 1 uses the above discussed properties to add the values of these properties to a ListBox control on a Form.  

listBox1.Items.Add("CommonAppDataPath: " + Application.CommonAppDataPath);

listBox1.Items.Add("CommonAppDataRegistry: " + Application.CommonAppDataRegistry.ToString());

listBox1.Items.Add("ExecutablePath: " + Application.ExecutablePath);

listBox1.Items.Add("LocalUserAppDataPath: " + Application.LocalUserAppDataPath);

listBox1.Items.Add("StartupPath: " + Application.StartupPath);

listBox1.Items.Add("UserAppDataPath: " + Application.UserAppDataPath);

 

Listing 2

The output of Listing 2 looks like Figure 2.

AppPathImg.jpg

Figure 2

Listing 3 is the VB.NET version of Listing 2.

listBox1.Items.Add("CommonAppDataPath: " + Application.CommonAppDataPath)

listBox1.Items.Add("CommonAppDataRegistry: " + Application.CommonAppDataRegistry.ToString())

listBox1.Items.Add("ExecutablePath: " + Application.ExecutablePath)

listBox1.Items.Add("LocalUserAppDataPath: " + Application.LocalUserAppDataPath)

listBox1.Items.Add("StartupPath: " + Application.StartupPath)

listBox1.Items.Add("UserAppDataPath: " + Application.UserAppDataPath)

 

Listing 3

Login to add your contents and source code to this article
share this article :
post comment
 

hi Mahesh Chand please I need a project convert RGB image to YUV in vb.net thank you very mach

Posted by hanan alsalamy Feb 01, 2012

i want to show code of vb.net exe file.....is it posible to decode vb file???????

Posted by sanket Mehta Aug 14, 2011
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor