gpt4 book ai didi

c# - 如何获取我的 .NET 应用程序的路径(而不是启动我的应用程序的应用程序的路径)

转载 作者:行者123 更新时间:2023-11-30 19:02:50 26 4
gpt4 key购买 nike

我无法在运行时获取我的应用程序的可执行文件的路径。此应用程序正在由另一个可执行文件启动,每当我尝试使用 Application.ExecutablePath 时,我都会得到该应用程序的路径,而不是我的路径。

Dim aPath1 As String = Application.ExecutablePath()
Dim aPath2 As String = Application.StartupPath()

在 C# 中会是

string aPath1 = Application.ExecutablePath;
string aPath2 = Application.StartupPath;

这些都没有给我执行这两行的程序的路径,它们只告诉我是什么程序启动了这个程序。

如有任何帮助,我们将不胜感激,在此先感谢您。

最佳答案

尝试

Assembly.GetExecutingAssembly().Location

参见 http://msdn.microsoft.com/en-us/library/system.reflection.assembly.location.aspx

关于c# - 如何获取我的 .NET 应用程序的路径(而不是启动我的应用程序的应用程序的路径),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8792441/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com