DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: exe path and filename at run-time

  1. #1
    Join Date
    Jan 2004
    Posts
    21

    exe path and filename at run-time

    I would like to get the full path and filename of the executable at run-time in either VB.NET or C#. This would be the counterpart to the App object in earlier versions of VB where I can use App.Path and App.EXEname. Also, what about the version information (App.Minor, App.Major, etc.)?

    Can anyone offer any help?


    Thank you,
    Jack

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    > App.Path and App.EXEname

    http://abstractvb.com/code.asp?A=1064

    > Also, what about the version information (App.Minor, App.Major, etc.)?

    If it doesn't already have one, add an Assembly Information file to your project (Project -> Add New Item -> Assembly Information File). That file (usually named AssemblyInfo.vb or .cs) will contain an AssemblyVersion attribute that looks something like this:

    <Assembly: AssemblyVersion("1.0.*")>

    (The asterisk tells VS.NET to automatically increment the version number on each build; you may override this behavior by hard-coding an explicit version number in the attribute.)

    Once you've assigned a version attribute to your assembly, you may obtain it at runtime like this:

    Dim AppVersion As String = System.Windows.Forms.Application.ProductVersion
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Jan 2004
    Posts
    21
    Phil,

    Thank you very much. The link gave me the information I needed. The application I am writing is a service app, and the last example is the one that worked. After I wrote the original message, I stumbled across the System.Windows.Forms.Application object, but of course it was not applicable to my service.

    FYI - The third example has an error. BaseDirectory is a property and not a method. The parenthesis should be removed.


    Thanks again,
    Jack Helfrich

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center