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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

770 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