Results 1 to 8 of 8

Thread: [2005] App.Path

  1. #1

    Thread Starter
    Hyperactive Member oyad's Avatar
    Join Date
    Feb 2003
    Location
    PhoxWare MicroSystems
    Posts
    463

    [2005] App.Path

    whats the best way to get the famous App.path in vb6 using vb.net 2005?i currently use this :
    Dim sRet As String = ""
    Try
    sRet = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase )
    sRet = sRet.ToLower
    If sRet.StartsWith("file:\") Then sRet = sRet.Substring(6)
    Catch ex As Exception
    Debug.Fail(ex.TargetSite.Name & vbNewLine & ex.Message)
    End Try
    Nobody is smarter than all of us!

  2. #2
    Junior Member
    Join Date
    Sep 2008
    Location
    Finland
    Posts
    20

    Re: [2005] App.Path

    You want to get application's path?
    Code:
    Application.ExecutablePath
    Teme64 @ windevblog.blogspot.com

  3. #3
    Member Artur Ramos's Avatar
    Join Date
    Sep 2006
    Location
    Lisbon - Portugal
    Posts
    32

    Re: [2005] App.Path

    You can use the 'Application.StartupPath', to get Application StartupPath Property.
    For example, to get the Application Directory Path:

    vb Code:
    1. Dim ApPath As String = Application.StartupPath
    2.         Dim Binpos As Integer
    3.  
    4.         Binpos = InStr(ApPath.ToUpper, "BIN")
    5.         If Binpos <> 0 Then ApPath = Mid(ApPath, 1, Binpos - 1)

    The 'Application.StartupPath' gives the "BIN" directory inside the Application directory.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] App.Path

    Just note that the Application class is a member of the System.Windows.Forms namespace, so if you're doing this in a Console app you'll have to stick with what you had originally.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: [2005] App.Path

    For console apps, couldn't he use Environment.CurrentDirectory?
    That is the very essence of human beings and our very unique capability to perform complex reasoning and actually use our perception to further our understanding of things. We like to solve problems. -Kleinma

    Does your code in post #46 look like my code in #45? No, it doesn't. Therefore, wrong is how it looks. - jmcilhinney

  6. #6
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [2005] App.Path

    Use My.Application.Info.DirectoryPath for console application.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] App.Path

    Quote Originally Posted by stanav
    Use My.Application.Info.DirectoryPath for console application.
    Cool. I thought that that was only available for Windows apps too but, as the documentation says, it's available for all but specifically Web projects.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Hyperactive Member oyad's Avatar
    Join Date
    Feb 2003
    Location
    PhoxWare MicroSystems
    Posts
    463

    Re: [2005] App.Path

    thanx 4 all ur contributions
    Nobody is smarter than all of us!

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