收到 VS2010 扩展的路径? [英] Receiving the path of a VS2010 extension?

查看:22
本文介绍了收到 VS2010 扩展的路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为 VS2010 编写了一个小的扩展(vsix 文件),在 vsix 中是一个二进制文件,它被扩展调用.

I've written a small Extension for VS2010 (vsix file), within the vsix is a binary file, which gets called by the extension.

我尝试像这样打开文件:

I try to open the file like this:

ProcessStartInfo startInfo = new ProcessStartInfo
                                             {
                                                 FileName = @".\Binaries\TFPT.exe"}

如果我调试所有内容,这很好用.但是如果我安装它,我会收到找不到文件"错误.二进制文件已正确安装.

Which works fine if I debug everything. But if I install it, I get a "file not found" error. The Binaries are installed correctly.

所以我想我尝试获取二进制文件的完整路径.但是我怎样才能得到路径呢?所有 Application.Path 信息都没有指向正确的路径.有没有办法获取扩展目录的路径?

So I thought I try to get the complete path to the binaries. But how can I get the path? All Application.Path infos are not pointing to the correct path. Is there a way to get the path of the extension directory?

路径类似于:C:\Users[username.domain]\AppData\Local\Microsoft\VisualStudio\10.0\Extensions[Company][ExtensionName]\1.0

The path is something like: C:\Users[username.domain]\AppData\Local\Microsoft\VisualStudio\10.0\Extensions[Company][ExtensionName]\1.0

没有手工制作的任何想法?

Any idea without putting it together by hand?

推荐答案

如何从当前正在执行的程序集中检索路径并将 Path.Combine() 与您剩余的相对路径段一起使用?

How about retrieving the path from the current executing assembly and use Path.Combine() with your the remaining relative path segment ?

注意:这段代码来自 SO answer.

Note: This piece of code comes from a SO answer.

private static string RetrieveAssemblyDirectory()
{
   string codeBase = Assembly.GetExecutingAssembly().CodeBase;
   var uri = new UriBuilder(codeBase);
   string path = Uri.UnescapeDataString(uri.Path);
   return Path.GetDirectoryName(path);
}

这篇关于收到 VS2010 扩展的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆