I’m working in C# Winforms, .net 4.0, and am designing some design-time components. My goal is to have the designer look for a specific file that resides in (either the project dir or the output dir).
Is there anyway for me to find the values of the following variables from code?
(Outpath)
(ProjectDir)
Well, it’s not so difficult if you can access the EnvDTE80.DTE2 representing your Visual Studio instance. In fact if dte is your instance of DTE2, it’s as simple as:
To get the DTE2 object is easy if you are writing an Add-In, since it is the first parameter passed to OnConnection (the wizard for the add-in projects automatically write code that put it in the _applicationObject variable of the Connect class).
If you have only the component, you can get the Site property, which implements ISite, which is derived from IServiceProvider, and ask it to get the DTE2. If compo is your component: