Getting the Current Directory

Sometimes you need to know what directory an application is actually running in – to load a config file for example. The code below finds the current directory of the application, sets it as the current directory, then loads a config file relative to that.

String path = Assembly.GetExecutingAssembly().Location;
path = Path.GetDirectoryName(path);

XmlDocument doc = new XmlDocument();

Leave a Reply

Your email address will not be published. Required fields are marked *