how to determine the directory from where app is loaded

D

dawn

Hi,

How can I determine the directory from which my app is started. Since upon
installation the user can decide in which directory to install the file...I
want to be able to load a file from a directory within that install
directory no matter what it is.
How best to deal with this?

Tx.
 
F

Frank Oquendo

dawn said:
How best to deal with this?

string path =
System.Reflection.Assembly.GetExecutingAssembly().Location;
System.IO.FileInfo info = new System.IO.FileInfo(path);
Console.WriteLine(info.DirectoryName);

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 
M

Michael Culley

another method

System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
 
G

Glenn B

Environment.CurrentDirectory

Gets and sets the fully qualified path of the current directory; that is,
the directory from which this process starts.

HTH

Glenn

This will return the directory
 
M

Matthew Slyh

I thought that Application.StartupPath gave us this information... Am I
missing something?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top