string pat = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase)
说明:
System.Reflection.Assembly.GetExecutingAssembly().CodeBase
取得应用程序的路径(包括程序名)
同样也适用于开发Windows Service
转载于:https://www.cnblogs.com/cai9911/archive/2007/12/19/1005684.html