通常我们WinForm编程时,要获取程序当前运行的文件夹路径会用Application.StartupPath ,但是Application.StartupPath在编写类库项目时却无法使用,因为我们根本无法用using System.Windows.Forms;来引入Application.StartupPath 的命名空间,这个时侯我们要用AppDomain.CurrentDomain.BaseDirectory。
private static string fullPathFileName = Application.StartupPath + "\\xxx.Ini"; //用于WINFORM
private static string fullPathFileName = AppDomain.CurrentDomain.BaseDirectory+"\\xxx.Ini"; //用于类项目
//获取了应用程序路径,不包括可执行文件名称。