Results 1 to 12 of 12

Thread: app.path equivalent

  1. #1

    Thread Starter
    Hyperactive Member Sneeden's Avatar
    Join Date
    Oct 2001
    Location
    Sneedville
    Posts
    258

    app.path equivalent

    does anyone know how to return the application path, like app.path in vb6?

  2. #2

    Thread Starter
    Hyperactive Member Sneeden's Avatar
    Join Date
    Oct 2001
    Location
    Sneedville
    Posts
    258
    Thanks fer thuh reply.

  3. #3
    zchoyt
    Guest
    Application.ExecutablePath gives the path including the EXE name.
    Application.StartupPath gives the path to the Dir :-)

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Originally posted by zchoyt
    Application.ExecutablePath gives the path including the EXE name.
    Application.StartupPath gives the path to the Dir :-)
    ...and in what manner does this differs to my response?

  5. #5
    zchoyt
    Guest
    Chill out!!
    I just read it quickly.
    I was just trying ro be helpful

  6. #6
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Originally posted by zchoyt
    Chill out!!
    I just read it quickly.
    I was just trying ro be helpful
    Oh I'm very relaxed
    I was just confused about your answer since it was exactly what I already posted.
    I was simply wondering if my reply was unclear in some way.

  7. #7
    zchoyt
    Guest
    np

  8. #8
    Addicted Member Dmyze's Avatar
    Join Date
    Mar 2002
    Location
    Seattle
    Posts
    160
    The proper replacement for app.path in VB.NET is System.Reflection.Assembly.GetExecutingAssembly.Location()

    (This will return the File Name of your exe at the end)

    Code:
        Dim sPath As String
    
        sPath = System.Reflection.Assembly.GetExecutingAssembly.Location()

    I use this to find the folder:

    Code:
        Dim oPath As System.IO.Path
        Dim sPath As String
    
        sPath = System.Reflection.Assembly.GetExecutingAssembly.Location()
        sPath = oPath.GetDirectoryName(sPath)
    -Daryl
    "Two More Rolls of Duct tape, and the world is mine!"
    VB.NET Guru

  9. #9
    zchoyt
    Guest

    Smile

    Well that' great and all, but I am using asp, not asp.net

  10. #10
    Tygur
    Guest
    Originally posted by zchoyt
    Well that' great and all, but I am using asp, not asp.net
    What does that have to do with anything?


    Originally posted by Dmyze
    The proper replacement for app.path in VB.NET is System.Reflection.Assembly.GetExecutingAssembly.Location()

    (This will return the File Name of your exe at the end)
    What makes that the "proper" replacement for app.path? Especially if it includes the EXE name and app.path omits it? I would venture to say that Application.StartupPath does the exact same thing as app.path did, and is therefore far more "proper" than what you gave.

  11. #11
    Addicted Member Dmyze's Avatar
    Join Date
    Mar 2002
    Location
    Seattle
    Posts
    160
    http://msdn.microsoft.com/library/de...albasicnet.asp

    "The App object in Visual Basic 6.0 was a global object used to set or retrieve information about the application. There is no direct equivalent for the App object in Visual Basic .NET; however, most of the properties can be mapped to equivalent properties in the .NET Framework."

    "Path = System.Reflection.Assembly.GetExecutingAssembly.Location "


    The Application.StartupPath is part of the System.windows.forms namespace. This is fine if you are writing a windows application in VB, however if you try to create a console application you won't have that name space available.

    System.Windows.Forms.Application.StartupPath()
    Last edited by Dmyze; Jun 22nd, 2002 at 01:04 PM.
    -Daryl
    "Two More Rolls of Duct tape, and the world is mine!"
    VB.NET Guru

  12. #12
    Tygur
    Guest
    Originally posted by Dmyze
    The Application.StartupPath is part of the System.windows.forms namespace. This is fine if you are writing a windows application in VB, however if you try to create a console application you won't have that name space available.
    Not by default, but all you have to do is add a reference to it, and it is available. And you'll still be writting a normal console app. It's not too hard.


    As for your quote, I would agree that it (that reflection one) is a valid replacement, which is all that quote seems to imply. But I wouldn't call it "the proper way", or even the "best way".

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width