2012-11-28 197 views
1

我的Visual Studio擴展生成一個URL,我想在Visual Studio中打開它作爲一個新選項卡。VSIX:打開瀏覽器窗口

我可以使用Process.Start()打開一個外部瀏覽器,但這看起來不太好。

我可以從磁盤使用此方法打開文件:

void OnOpenBrowserWindow(string url) 
    { 
    if (url != null) 
    { 
     IVsCommandWindow service = (IVsCommandWindow) this.GetService(typeof (SVsCommandWindow)); 
     if (service != null) 
     { 
      string command = string.Format("File.OpenFile \"{0}\"", url); 
      service.ExecuteCommand(command); 
     } 
    } 
    } 

,但它並不適用於網址

回答

1

最簡單的方法是使用ItemOperations.Navigate()方法工作。

var itemOps = Dte.ItemOperations; 
itemOps.Navigate("http://bing.com"); 
+0

這使我的一天,作爲一種魅力! –

相關問題