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

原文地址:https://www.cnblogs.com/tommy-huang/p/4612688.html