Find Install directory and working directory of VSTO Outlook Addin; or any Office Addin

前端 未结 5 1268
攒了一身酷
攒了一身酷 2020-12-06 02:40

I created a VSTO Outlook Addin that uses a library Html2Xhtml.dll (.NET) which calls another Html2xhtml.exe by executing System.Diagnostic.Process.Start().

However,

5条回答
  •  广开言路
    2020-12-06 03:13

    I found the answer here, full credits to 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());
    

提交回复
热议问题