How do I find the application\'s path in a console application?
In Windows Forms, I can use Application.StartupPath
to find the current path, but this d
in VB.net
My.Application.Info.DirectoryPath
works for me (Application Type: Class Library). Not sure about C#... Returns the path w/o Filename as string
I have used
System.AppDomain.CurrentDomain.BaseDirectory
when I want to find a path relative to an applications folder. This works for both ASP.Net and winform applications. It also does not require any reference to System.Web assemblies.
Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName)
Is the only one that has worked for me in every case I have tried.