/// <summary>
/// Returns the application path
/// </summary>
/// <returns></returns>
public static string GetApplicationPath()
{
String s = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
s = System.IO.Path.GetDirectoryName(s);
s = new Uri(s).LocalPath;
return s;
}
Single line version:
string path = new Uri(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase)).LocalPath;
Get the path from the application folder with additional filename:
string path = new Uri(Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase), "log4net.config")).LocalPath;
String tempPath = Path.GetTempPath();
String appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);