VS2008和C#:我在C#中的哪个位置(来自.exe文件)? [英] VS2008 and C#: Where am I in C# (from .exe file) ?
问题描述
让可执行文件在哪个文件夹(在哪个文件夹中)启动的最佳方法是什么?可执行文件需要完整的文件夹地址,例如来自"C:".
What is the best way to let know an .exe file where (in which folder) the executable was started ? The executable needs a full folder address, e.g. from "C:".
谢谢
推荐答案
从您的帖子中了解到,您正在尝试来获取正在运行的应用程序的位置.
我找到了一篇谈论它的文章,您可能看看:
http://www.zayko.net/post/How-to-get -running-running-Assembly-(C).aspx
摘录自上一篇文章:
您可以使用以下方式获取它:
如果您使用的是Windows Forms App,您可以拨打此电话:
If you are working on a Windows Forms App, you can make this call:
System.IO.Path.GetDirectoryName(Application.ExecutablePath);
在非WinForms应用中使用此功能:
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
In non-WinForms Apps use this:
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
如果不是这种情况,请放心让我知道.
最好的问候,
Harry Zhu- MSFT
Harry Zhu- MSFT
论坛中的MSDN订阅者支持
如果您对我们的支持有任何反馈,请接触 msdnmg@microsoft.com
If you have any feedback of our support, please contact msdnmg@microsoft.com
这篇关于VS2008和C#:我在C#中的哪个位置(来自.exe文件)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!