gpt4 book ai didi

c# - 获取 wcf 服务程序集中文件的路径

转载 作者:太空狗 更新时间:2023-10-29 23:26:12 24 4
gpt4 key购买 nike

我有一个由 IIS 中托管的 WCF 服务引用的程序集。该程序集使用了一些 XSLT 文件,我很困惑将这些文件转储到哪里,要么在程序集项目本身中创建一个文件夹,要么在 WCF 服务端创建一个文件夹,以及如何在程序集中获取 xslt 文件的物理路径?

最佳答案

由于 IIS 托管的 WCF 服务只倾向于将 DLL 复制到临时文件夹而不是设置为复制到输出的项目内容,因此需要引用 dll 的实际代码库。

var codeBase = System.Reflection.Assembly.GetCallingAssembly().CodeBase;
codeBase = codeBase.Substring(8); //Remove the "file:///" prefix in front of the actual path.

var dir = codeBase.Substring(0, codeBase.LastIndexOf("/", System.StringComparison.Ordinal) + 1); //Cut out the dll file name.

var file = @"ErrorMessages.xml";

var targetPath = dir + file;

关于c# - 获取 wcf 服务程序集中文件的路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6176448/

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