// 擷取程式工作路徑的 n 種方法。
string tmp =
System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
tmp =
System.Environment.CurrentDirectory;
System.IO.Directory.GetCurrentDirectory();
System.Windows.Forms.Application.StartupPath;
System.Windows.Forms.Application.ExecutablePath;
//針對網站應用程式有效的 m 種方法。
tmp
= System.AppDomain.CurrentDomain.BaseDirectory;
System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
HttpContext.Current.Request.PhysicalApplicationPath;