473,396 Members | 2,013 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,396 software developers and data experts.

How to determine folder .exe was run from?

I am trying to find a way to determine what drive and folder path a
executable is run from (and them pass that as the defaul in a BrowseForFolder
dialog).

In VB6, there was a way to do this, reading the App.Path property. What is
the equivalent in Visual Basic .NET?
Nov 21 '05 #1
8 5148
Use:

System.AppDomain.CurrentDomain.BaseDirectory()

if you want you can make a function to do this:

\\
Public Function AppPath() as String
Return System.AppDomain.CurrentDomain.BaseDirectory()
End Function
//

Hope this helps,
Norst

On Sat, 23 Apr 2005 21:13:01 -0700, "Jethro Bodine"
<Je**********@discussions.microsoft.com> wrote:
I am trying to find a way to determine what drive and folder path a
executable is run from (and them pass that as the defaul in a BrowseForFolder
dialog).

In VB6, there was a way to do this, reading the App.Path property. What is
the equivalent in Visual Basic .NET?

Nov 21 '05 #2
Hi Jethro

They made it more pricise what it is.

application.startuppath

I hope this helps,

Cor
Nov 21 '05 #3

hmmmmm

i use this
System.Environment.CurrentDirectory

as i found that application.startuppath fails on dll`s



"Cor Ligthert" <no************@planet.nl> wrote in message
news:eG*************@TK2MSFTNGP10.phx.gbl...
Hi Jethro

They made it more pricise what it is.

application.startuppath

I hope this helps,

Cor

Nov 21 '05 #4
"M. Posseth" <mi*****@nohausystems.nl> schrieb:
i use this
System.Environment.CurrentDirectory


Note that the current directory can be changed while the application is
running, for example, when using a 'FileDialog'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #5
"Jethro Bodine" <Je**********@discussions.microsoft.com> schrieb:
I am trying to find a way to determine what drive and folder path a
executable is run from (and them pass that as the defaul in a
BrowseForFolder
dialog).


In Windows Forms applications you can use 'Application.StartupPath'. For
class libraries and other types of applications, you may want to use the
code below:

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

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #6
Thanks Herfried

Indeed i should better use a alternative method

however in my situation this will not happen so soon ,,,, just looked in
the code where i currently use it
they are web projects , and Dll`s ( but it is a potential big )

in my executables i use application.startuppath

however i found that this will not work in a Dll

i wonder if this will work in both executables as dll`s

System.AppDomain.CurrentDomain.BaseDirectory()

cause it sounds to me as a better generic alternative ( if this works
ofcourse in both )


"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eh**************@TK2MSFTNGP12.phx.gbl...
"M. Posseth" <mi*****@nohausystems.nl> schrieb:
i use this
System.Environment.CurrentDirectory


Note that the current directory can be changed while the application is
running, for example, when using a 'FileDialog'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #7
But Herfried, that will only give you the current assembly & not a different
one executing as a different process. So, you cannot really use it.

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #8
"Crouchie1998" <cr**********@spamcop.net> schrieb:
But Herfried, that will only give you the current assembly & not a
different
one executing as a different process. So, you cannot really use it.


I understand what you mean, but the OP clearly stated that he is looking for
an equivalent of VB6's 'App.Path'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #9

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

Similar topics

4
by: Bart Plessers \(artabel\) | last post by:
Hello, I have an asp script that lists the files in a directory: CurrentPATH = "c:\temp\" Set oFSO = CreateObject("Scripting.FileSystemObject") Set oFolder = oFSO.GetFolder(CurrentPATH) Set...
2
by: atse | last post by:
Hi, I still don't know how to determine a empty folder. Can you tell me more detail? thanks Atse "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message...
3
by: Web Webon | last post by:
Hi everybody! I wonder if this is possible? I need to determine if a client is using "windows classic folders" or anything else. If I instantiate a Shell ActiveX object is there a way of...
13
by: could ildg | last post by:
I want to check if a folder named "foldername" is empty. I use os.listdir(foldername)== to do this, but it will be very slow if the folder has a lot of sub-files. Is there any efficient ways to do...
1
by: Tim Marsden | last post by:
HI If I have 2 strings each containing a Path string, but in different formats. e.g. 1. "D:\My Folder\My Sub Folder\A.txt" and 2. "\\ComputerA\Share B\A.txt" Now do I compare these to...
7
by: Stephen E. Weber | last post by:
I need to determine if a file exists using code. I tried using the system.io.file.exists function, that will appears to locate the file if I use the complete filespec, when I move the project to...
3
by: Dennieku | last post by:
Hi, I've have 2 questions about the Web Setup project in VS.Net 2003. 1. How can i determine, from an Installer class, in which folder the Website has been installed (at the Commit phase) 2. I...
1
by: topramen | last post by:
does any one here know of a good way to to determine whether or not a given path is a directory (e.g., "c:\mydir") or a file (e.g., "c:\mydir \myfile.txt")? i started attacking this problem by...
9
by: Scott | last post by:
What is the most reliable method to determine the folder a script is running in? I was looking at the globals in $_SERVER but all the variables also listed the actual file the script was running...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.