eHow launches Android app: Get the best of eHow on the go.

How To

How to Get App.Path and App.EXEName in VB.NET

Member
By Adam Murray
User-Submitted Article
(0 Ratings)

Many VB.NET coders miss the simplicity of the VB6 App object. With a little bit of code, many of the App object's properties can be replicated in VB.NET. This article shows you how to replicate the App.EXEName and App.Path properties.

Difficulty: Easy
Instructions

Things You'll Need:

  • Visual Basic .NET (any version)
  1. Step 1

    Add a project reference to the System.Windows.Forms component, if your project doesn't already contain one.

  2. Step 2

    Add the line "Imports System.Windows.Forms" to the top of the module that will contain the App class.

  3. Step 3

    Add a public class named App to your module.

  4. Step 4

    Add two public shared readonly properties, named Path and ExeName, to the App class. Both properties will return an object of type String.

  5. Step 5

    In the Path getter, add this line of code:

    Return System.IO.Path.GetDirectoryName(Application.ExecutablePath)

  6. Step 6

    In the ExeName getter, add this line of code:

    Return System.IO.Path.GetFileName(Application.ExecutablePath)

  7. Step 7
    Sample console application calling the App class.
     
    Sample console application calling the App class.

    The properties App.Path and App.ExeName will now be accessible in your .NET application, and should return the same values as you would have seen in a VB6 application.

Subscribe

Post a Comment

Post a Comment

Related Ads

  • Have you done this? Click here to let us know.
I Did This
Get Free Computers Newsletters

Copyright © 1999-2009 eHow, Inc. Use of this web site constitutes acceptance of the eHow Terms of Use and Privacy Policy .   en-US Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License. † requires javascript

eHow Computers
eHow_eHow Technology and Electronics