WPF获取程序启动路径(StartupPath)

1. 在传统的Winform中获取

     可以使用: 

Application.StartupPath

Application.ExecutablePath

  很可惜,这些方法,在WPF中都失效啦

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

  其中Process的头文件是: 

 using System.Diagnostics;

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

  

参考:http://www.silverlightchina.net/html/study/WPF/2011/0706/8826.html

posted @ 2015-07-01 10:57  一菲聪天  阅读(3854)  评论(0编辑  收藏  举报