string pat = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase)
说明:
System.Reflection.Assembly.GetExecutingAssembly().CodeBase
取得应用程序的路径(包括程序名)

同样也适用于开发Windows Service

相关文章: