获取Windows应用程序的可执行路径 [英] Get Executable Path of Windows Application

查看:102
本文介绍了获取Windows应用程序的可执行路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想得到我的Windows应用程序的可执行路径。

我应该使用

System.Reflection.Assembly.GetExecutingAssembly()。GetName()。CodeBase ;



Application.ExecutablePath;



哪个最好......?请回复...

解决方案

首先,请阅读我的评论。



最好的方法不存在。这取决于你的需求...



在这里阅读差异:

如何:确定执行应用程序的路径 [ ^ ]

Application.ExecutablePath属性 [ ^ ]

在WPF(C#或vb.net)中查找应用程序可执行文件的位置? [ ^ ]

你会发现这里的不同之处:最佳方式获取应用程序文件夹路径 [ ^ ]



我发现链接使用谷歌 [<一个HREF =https://www.google.co.in/search?q=Application.ExecutablePath&ie=utf-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox -a&安培;信道= RCS&安培; gws_rd = CR#客户=火狐-A和HS = OQL&安培; RLS = org.mozilla:EN-US%3Aofficial&安培;信道= RCS&安培; sclient = PSY-AB&安培; q = application.executablepath + VS + getexecutingassembly&安培; OQ = Application.ExecutablePath + VS +&安培; gs_l = serp.1.1.0i22i30l2j0i8.1733.3084.0.6813.4.4.0.0.0.0.636.2362.5-4.4.0 .... 0 ... 1c.1.23。 PSY-ab..0.4.2345.TPkYJZj57Y8&安培; PBX = 1&安培; BAV = on.2,or.r_cp.r_qf&安培; BVM = bv.49967636,d.dmg&安培; FP = 13c281cb7233c80b&安培; BIW = 1280&安培;波黑= 646 target =_ blanktitle =New Window> ^ ]。在发布之前,请在Google / Bing上进行搜索。它不仅会在大多数情况下为您提供答案,而且会为您节省大量时间。


您好,

Application.ExecutablePath - 这样会好的。



首先使用命名空间

 使用 System.IO; 





获取可执行路径

  string  path = Path.GetDirectoryName(Application.ExecutablePath); 


I want to get the Path of Executable of my windows Application.
Should I use
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;
or
Application.ExecutablePath ;

Which is best... ? Please Reply...

解决方案

First of all, please, read my comment.

The "best method" doesn't exists. It depends on your needs...

Read about the difference here:
HOW TO: Determine the Executing Application's Path[^]
Application.ExecutablePath Property [^]
Find the location of my application's executable in WPF (C# or vb.net)?[^]


You will find the difference here: Best way to get application folder path[^]

I found the link using Google[^]. Do search on Google/Bing before you post. It will not only give you the answer in most cases but it will save you a lot of time.


Hi,
Application.ExecutablePath - This will be fine.

First use the namespace

using System.IO;



To get the Executable Path

string path = Path.GetDirectoryName(Application.ExecutablePath);


这篇关于获取Windows应用程序的可执行路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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