App.Path replacement in VB.NET

Posted on 2005-03-18
Medium Priority
Last Modified: 2008-02-01
Hello me again.

Still working on learning VB.Net by way of re-doing an "Error Log" type module I had in VB6. (my way of saying there will probably be a few questions posted in the VB.NET channel over the next few days/weeks while I learn.

Anyway, That being said.......

I tried could use  System.Reflection.Assembly.GetExecutingAssembly.Location   but that also includes the name of the .exe. "C:\testprogram\test.exe"

Now I think I could make some handy little function to strip everything off after the last "\" but is there a different function I should be useing?

Question by:ScottParker
  • 2
LVL 28

Accepted Solution

iboutchkine earned 1000 total points
ID: 13574184
here are several ways to do it

This is the property of shortcuts (aka start in) or if no shortcut then its the path of the executible
Dim a As String = Application.StartupPath
This is the "Environments" current Directory (can change)
Dim b As String = Environment.CurrentDirectory
Public Apath As String = System.Environment.CurrentDirectory
    FileCopy(Apath & ".\images\Yellow.jpg", ofile1 & "Yellow.jpg")

This is the proper way of getting you applications path, (Application.ExecutablePath is the path including
your executable file)
Dim c As String = IO.Path.GetDirectoryName(Application.ExecutablePath)


Author Comment

ID: 13574267
       Dim path As String = Environment.CurrentDirectory

That worked. Thanks.
LVL 28

Expert Comment

ID: 13575287
You are welcome

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question