gpt4 book ai didi

c# - 在 .Net 中获取实际的 dll 路径

转载 作者:行者123 更新时间:2023-11-30 19:29:08 25 4
gpt4 key购买 nike

我有一个名为 JIMS.Printing.dll 的 dll,它位于主应用程序 JIMS.exe 的 Reporting 文件夹中。

但是在运行 JIMS.exe 的 Reporting 中的 JIMS.Printing.dll 代码中调用 Templates 文件夹中的某些文件时出现错误

JIMS.exe
--------->Reporting
------------------->JIMS.Printing.dll
------------------->Templates
-----------------------------> Files

代码:

string _templatePath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(JIMS.Printing.PrintInvoice)).Location), "Templates");

来自 JIMS.Printing.dll 的代码

JIMS.exe 在 JIMS.exe Path\Templates\file 中寻找文件,但实际上文件在 JIMS.Printing.dll Path\Templates\files

最佳答案

您可以使用:

Assembly.GetExecutingAssembly().Location

这将为您提供执行程序集的路径,然后使用:

System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)

这将给出包含的文件夹。

关于c# - 在 .Net 中获取实际的 dll 路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13200880/

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