On TV.com: ANGELINA JOLIE looks stunning as usual

Locate the executable path using VB.NET

Tags: Microsoft development tools, Programming languages, Irina Medvinskaya, ListBox1, Microsoft Visual Basic, StartUpPath, Microsoft Visual Basic.Net, Visual Basic Tips Newsletter

  • Save
  • Print
  • Digg This
  • 7

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!

  • Save
  • Print
  • Digg This
  • 7

Print/View all Posts Comments on this article

And for the rest of us, here's the code for VB6ChuckSomerville  | 10/13/06
Tweak to the VB6 codepmitchell@...  | 06/02/08
Example doesn't work as listedpweegar@...  | 10/17/06
Design time path for web formsInteXX  | 02/16/07

What do you think?

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

Cracking Open

advertisement
Click Here