问题描述
我创建了一个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?
推荐答案
我找到了答案找到用于vsto-add-in/"rel =" noreferrer>">的部署文件,这要完全归功于robindotnet.wordpress.com.
I found the answer here, full credits to robindotnet.wordpress.com.
//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插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!