2010-03-02 66 views

回答

2

我爲我的宏編寫了這個函數,它通過子字符串搜索完全絕對輸出路徑。

Function FindOutBinaryNameByExtension(ByVal prj As EnvDTE.Project, ByVal extName As String) As String 
    FindOutBinaryNameByExtension = Nothing 

    Dim cm As ConfigurationManager = prj.ConfigurationManager 
    If cm IsNot Nothing Then 
     Dim ac As Configuration = cm.ActiveConfiguration 
     For Each grpOut In ac.OutputGroups 
      If grpOut.DisplayName = "Primary output" Then 
       Dim lst As Array = grpOut.FileURLs 
       For i As Long = 0 To lst.Length - 1 
        Dim fileName As String = lst.GetValue(i) 
        If fileName.Contains(extName) Then 
         FindOutBinaryNameByExtension = fileName 
         Exit Function 
        End If 
       Next 
      End If 
     Next 
    End If 
End Function 
+0

很好的答案,正是我所期待的。謝謝! – 2012-05-27 12:57:52

相關問題