找到VSTO Outlook Addin的安装目录和工作目录;或任何 Office 插件

编程入门 行业动态 更新时间:2024-10-09 18:22:56
本文介绍了找到VSTO Outlook Addin的安装目录和工作目录;或任何 Office 插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个 VSTO Outlook 插件,它使用一个库 Html2Xhtml.dll (.NET),它通过执行 System.Diagnostic.Process.Start() 调用另一个 Html2xhtml.exe.

I created a VSTO Outlook Addin that uses a library Html2Xhtml.dll (.NET) which calls another Html2xhtml.exe by executing System.Diagnostic.Process.Start().

但是,它无法调用 Html2xhtml.exe(我认为),因为即使从 Visual Studio 启动,工作目录也是当前用户的我的文档"文件夹.我无法控制 Html2Xhtml.dll 中的代码,所以我不能使用绝对路径;但我想我可以在运行时更改加载项的工作目录.

However, it fails to call Html2xhtml.exe (i think) because the working directory even when launched from Visual Studio is the current user My Documents folder. I have no control over the code in Html2Xhtml.dll so I cannot use absolute path; but I suppose I can change the working directory of the Add-in at runtime.

但是,如果我通过 ClickOnce 或其他一些我不知道用户将选择的安装路径的方式安装它,我怎么能找到我的 Html2xhtml.exe?

However, If I install this via ClickOnce or some other means where I do not know the install path the user is going to choose, how am I suppose to find my Html2xhtml.exe?

推荐答案

我找到了答案 此处,全部归功于 robindotnet.wordpress.

I found the answer here, full credits to robindotnet.wordpress.

//Get the assembly information
System.Reflection.Assembly assemblyInfo = System.Reflection.Assembly.GetExecutingAssembly();

//Location is where the assembly is run from 
string assemblyLocation = assemblyInfo.Location;

//CodeBase is the location of the ClickOnce deployment files
Uri uriCodeBase = new Uri(assemblyInfo.CodeBase);
string ClickOnceLocation = Path.GetDirectoryName(uriCodeBase.LocalPath.ToString());

这篇关于找到VSTO Outlook Addin的安装目录和工作目录;或任何 Office 插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-03-29 13:07:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/756975.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:安装目录   插件   目录   工作   Outlook

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!