string path = AppDomain.CurrentDomain.BaseDirectory
/*This is the best option all round.
It will give you the base directory for class libraries,
including those in ASP.NET applications.*/
string startupPath = System.IO.Directory.GetCurrentDirectory();
/*
This does an interop call using the winapi GetCurrentDirectory call inside kernel32.dll,
which means the launching process’ folder will often be returned.
Also as the MSDN documents say, it’s not guaranteed to work on mobile devices.
*/
string startupPath = Environment.CurrentDirectory;
/*
This simply calls Directory.GetCurrentDirectory()
*/
Assembly.Location
/*
called using : this.GetType().Assembly.Location
This returns the full path to the calling assembly,
including the assembly name itself.
If you are calling a separate class library,
then its base directory will be returned,
such “C:\myassembly.dll” – depending obviously on which Assembly instance is being used.
*/
Application.StartupPath
/*
This is inside the System.Windows.Forms namespace,
so is typically used in window forms application only.
*/
Application.ExecutablePath
/*
The same as Application.StartupPath,
however this also includes the application name, such as “myapp.exe”
*/
get current project path
最新推荐文章于 2022-07-28 17:51:10 发布