473,408 Members | 2,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

AppPath() replacement

Hi

How do I get the path where application is running?

TIA

A.B.
Nov 20 '05 #1
7 1390
Application.StartupPath()

"Analia Beltran" <an*******@discussions.microsoft.com> wrote in message
news:AB**********************************@microsof t.com...
Hi

How do I get the path where application is running?

TIA

A.B.

Nov 20 '05 #2
* "=?Utf-8?B?QW5hbGlhIEJlbHRyYW4=?=" <an*******@discussions.microsoft.com> scripsit:
How do I get the path where application is running?


\\\
Imports System.IO
Imports System.Reflection
..
..
..
Private Function ApplicationPath() As String
Return _
Path.GetDirectoryName([Assembly].GetExecutingAssembly().Location)
End Function
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
Use System.Environment.CurrentDirectory:

'on a console app:
Module Module1

Sub Main()
Console.WriteLine(System.Environment.CurrentDirect ory())
End Sub

End Module
Nov 20 '05 #5
* am****@online.microsoft.com (Alexandre Moura) scripsit:
Use System.Environment.CurrentDirectory:

'on a console app:
Module Module1

Sub Main()
Console.WriteLine(System.Environment.CurrentDirect ory())
End Sub


This doesn't always return the application's startup path.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #6
System.Environment.CurrentDirectory() simply returns the current directory
(which can change during execution or by starting the program with a
shortcut with a different "Start In" setting.

According to the Help (look under "App Object Changes"), the official
replacement for App.Path is:

System.Reflection.Assembly.GetExecutingAssembly.Lo cation

Beware, because this returns the filename of the Exe or dll as well - you'll
need to strip this off to get the directory. Also if the code is in a dll
that is in a different directory than your current application, it will
return that path instead.

If you want to get the path of the main executable that started the
application, use

System.Reflection.Assembly.GetEntryAssembly.Locati on

Instead

Hope this helps,

Trev.


"Alexandre Moura" <am****@online.microsoft.com> wrote in message
news:9L**************@cpmsftngxa07.phx.gbl...
Use System.Environment.CurrentDirectory:

'on a console app:
Module Module1

Sub Main()
Console.WriteLine(System.Environment.CurrentDirect ory())
End Sub

End Module

Nov 20 '05 #7
Yep, you guys are right.

--------------------
From: hi***************@gmx.at (Herfried K. Wagner [MVP])
Newsgroups: microsoft.public.dotnet.languages.vb
Subject: Re: AppPath() replacement
Date: 05 Dec 2003 00:22:18 +0100
Lines: 15
Sender: Administrator@FAMILIE-IF1R60H
Message-ID: <bq*************@ID-208219.news.uni-berlin.de>
References: <AB**********************************@microsoft.co m> <9L**************@cpmsftngxa07.phx.gbl>NNTP-Posting-Host: v208-105.vps.tuwien.ac.at (128.131.208.105)
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.uni-berlin.de 1070580438 72323595 128.131.208.105 ([208219])
X-Face: vJn^g[Lkg9YfJ,Oj#{Y[')WBo<1kS#Rc3Vb!D;jf$;OZ%<"'z+DX"K/m)h\Gi;e-AYsc%'CmL~Ix
@YEq$}A>^]KbF1.Z|=/'*CcB[f+8(m&vP.u4+P.q$n]?[s>nnFu/8EuC?h[c\#wR{ok_um~57to=
P=1"{qO1e%A2~nS?<[o`jn?C/-}7Mbz~L)WI=5VL!*xU#^dUser-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Common Lisp (Windows)) Hamster/2.0.0.1Path: cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTN GXA06.phx.gbl!TK2MSFTNGXA0
5.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!newsfeed01.sul.t-o
nline.de!t-online.de!fu-berlin.de!uni-berlin.de!v208-105.vps.tuwien.ac.AT!no
t-for-mailXref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.vb:161503
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

* am****@online.microsoft.com (Alexandre Moura) scripsit:
Use System.Environment.CurrentDirectory:

'on a console app:
Module Module1

Sub Main()
Console.WriteLine(System.Environment.CurrentDirect ory())
End Sub


This doesn't always return the application's startup path.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>


Nov 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Arjen | last post by:
Hello, I want to check if an directory exist. Directory.Exists(Application + "/Uploads/") I'm doing this inside a asp.net web project in a class file. Here is the error message. The name...
1
by: dave | last post by:
I need to put the port for my server to get to my web site. example: http://mysite:81 when I use Application("AppPath") , it dumps the :81 What can I do???
0
by: msn | last post by:
I have the Sub in global.asa. It works on my server, but does not work when I upload to the web server? img src="<%= Application("AppPath")%>/images/btn_topslash2.gif" Sub...
2
by: Arjen | last post by:
Hi, Is this Application + "/error.aspx" and this "~/error.aspx" always the same?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.