How can i Get application Path

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created a project in "c:\myproject\" directory

how can i access this path in c#.
I have a XML File in this same directory and i want to load this file
using xmldom.load method.
 
girdhar said:
I have created a project in "c:\myproject\" directory

how can i access this path in c#.
I have a XML File in this same directory and i want to load this file
using xmldom.load method.
AppDomain.CurrentDomain.BaseDirectory can return the running assembly path.
 
Gabriel said:
System.Environment.CurrentDirectory

Gabriel Lozano-Morán

Environment.CurrentDirectory returns the fully qualified path of the current directory; that is, the directory from which this process starts.
 
the current directory; that is, the directory from which this process starts.

The current directory isn't necessarily the startup directory.



Mattias
 
You can change the current directory using
System.IO.Directory.SetCurrentDirectory() I was wrong to assume that his
..EXE runs in c:\myproject\

Gabriel Lozano-Morán
 
public class Globals
{
public static string AppHomeDir; // app’s home dir (e.g. where .EXE
lives)
static Globals()
{
AppHomeDir = System.AppDomain.CurrentDomain.BaseDirectory;
}
}
 
Back
Top