How do I get the default project creation directory from within a Visual Studio 2010 extension? By default this directory is:
C:\Users\<username>\Documents\Visual Studio 2010\Projects
I’m guessing this is done via the Tools->Options window, but I don’t know how to get at this via the SDK.
At first glance the following looks like it should get me close:
DTE2 dte = CType(GetService(typeof(SDTE)), DTE2);
Object props = dte.Properties("Projects and Solutions", "General");
But I get the following error:
System.Runtime.InteropServices.COMException was unhandled by user code
ErrorCode=-2147352565
Message=Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
Found it:
http://msdn.microsoft.com/en-us/library/ms165642.aspx
And here’s the code to get the values I’m looking for:
Note that the values in the registry don’t match up with what you see in Visual Studio so a little detective work is required to get to the exact value that you’re looking for. I assume that it’s setup this way due to backward compatibility.