Locate the executable path using VB.NET
Takeaway: In this Visual Basic .NET tip, Irina Medvinskaya looks at a simple way to determine the path where the current executable resides.
It is often useful to be able to determine the path where the current executable resides. A simple way to do this using Visual Basic .NET is to read the value of the StartUpPath property of the Application class. This can also be achieved by determining the current working path or utilizing reflection to determine the code base location of the currently executing assembly.
Example
In order to demonstrate finding the executable path, add the listbox control ListBox1 to the form and add the code in Listing A. (Note: You must use theSystem.Windows.Forms namespace to use the technique in this example.) When you run the code, your result will look like Figure 1.
In this example, I utilize the System.Windows.Forms namespace and initially get the ExecutablePath property of the Application class. The value is displayed in ListBox1. Then, I get the StartUpPath property of the Application class and also display it in ListBox1.
Miss a tip?
Check out the Visual Basic archive, and catch up on the most recent editions of Irina Medvinskaya's column.
Advance your scripting skills to the next level with TechRepublic's free Visual Basic newsletter, delivered each Friday. Automatically sign up today!
Print/View all Posts Comments on this article
SponsoredWhite Papers, Webcasts, and Downloads
- Using Emotional Intelligence in the Technical Professions Global Knowledge
- SharePoint: How It's Leveraged and How It Works Global Knowledge
- Eleven Myths about 802.11 Wi-Fi Networks Global Knowledge
Article Categories
- Security
- Security Solutions, IT Locksmith
- Networking and Communications
- E-mail Administration NetNote, Cisco Routers and Switches
- CIO and IT Management
- Project Management, CIO Issues, Strategies that Scale
- Desktops, Laptops & OS
- Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
- Data Management
- Oracle, SQL Server
- Servers
- Windows NT, Linux NetNote, Windows Server 2003
- Career Development
- Geek Trivia
- Software/Web Development
- Web Development Zone, Visual Basic, .NET





