2014-09-29 68 views
2

我在Visual Studio 2012中编写了一个Outlook插件,我需要它运行一个.exe文件。Office(Outlook)AddIn和EXE文件

问题是:当我将.exe添加到我的项目时,它将它放入bin \ debug或bin \ release文件夹中。 但是,插件从Office文件夹运行,所以它没有连接到我的.exe文件。

这应该怎么做?

回答

2

你的插件是从Office文件夹运行的吗?你确定这是它安装的地方吗?还是因为你正在检索主机应用程序的位置(这将是Outlook.exe)?要检索插件的位置,请使用以下内容:

//use CodeBase instead of Location because of Shadow Copy. 
string codebase = Assembly.GetExecutingAssembly().CodeBase; 
var vUri = new UriBuilder(codebase); 
string vPath = Uri.UnescapeDataString(vUri.Path + vUri.Fragment); 
string directory = Path.GetDirectoryName(vPath); 
if (!string.IsNullOrEmpty(vUri.Host)) directory = @"\\" + vUri.Host + directory; 
+0

您完全正确!我检查了当前的目录...谢谢! – SharonKo 2014-09-29 14:12:28