Jak*_*ake 8 clickonce outlook vsto working-directory
我创建了一个使用库Html2Xhtml.dll(.NET)的VSTO Outlook Addin,它通过执行System.Diagnostic.Process.Start()调用另一个Html2xhtml.exe.
但是,它无法调用Html2xhtml.exe(我认为)因为即使从Visual Studio启动工作目录也是当前用户的My Documents文件夹.我无法控制Html2Xhtml.dll中的代码,所以我不能使用绝对路径; 但我想我可以在运行时更改外接程序的工作目录.
但是,如果我通过ClickOnce或其他一些我不知道用户将要选择的安装路径的方式安装它,我怎么想找到我的Html2xhtml.exe?
Jak*_*ake 20
我在这里找到了答案,完全归功于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());
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17107 次 |
| 最近记录: |