how to determine the directory from where app is loaded

  • Thread starter Thread starter dawn
  • Start date Start date
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.
 
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)
 
another method

System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
 
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
 
I thought that Application.StartupPath gave us this information... Am I
missing something?
 
Back
Top