WPF Framework 3.5上的C#Application.ExecutablePath [英] C# Application.ExecutablePath on WPF Framework 3.5

查看:371
本文介绍了WPF Framework 3.5上的C#Application.ExecutablePath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此行在WinForm Framework3.5中很好,但在WPF Framework3.5中不行.

This line is fine in a WinForm Framework3.5 but not in a WPF Framework3.5.

Path.GetDirectoryName(Application.ExecutablePath); 

如何在WPF应用程序上获取exe路径?

How can I get the exe path on a WPF app ?

推荐答案

有几种获取exe路径的方法.尝试下一个:

There are several ways to get exe path. Try the next:

  • Application.StartupPath
  • Path.GetDirectoryName(Environment.GetCommandLineArgs()[0])
  • Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName)
  • Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)
  • System.Reflection.Assembly.GetEntryAssembly().Location

这篇关于WPF Framework 3.5上的C#Application.ExecutablePath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆