WPF获取程序自身的启动路径

原来在Windows Form程序中,获取自身的启动目录是非常容易的,可以使用

Application.StartupPath

Application.ExecutablePath

但是,这些方法,在WPF中都失效啦

在WPF中获取自身的启动路径,是采用进程的方式来获取的

String appStartupPath = System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);

posted @ 2011-08-12 09:17  徐文峰  阅读(4443)  评论(1编辑  收藏  举报