A simple question for which I couldn't find a setting or an answer:
I relocated my Documents folder in Windows to another drive. How do I change the My Code Snippets folder path in Visual Studio 2012 from the default to the new location?
The default is in my Documents folder on C:.
C:\Users\Virtlink\Documents\
Visual Studio 2012\Code Snippets\Visual C#\My Code Snippets
But I moved my Documents folder to my drive D:, but Visual Studio didn't pick up on this change and forces the creation of the folder on C:. This causes some weird behavior with exclamation marks next to My Code Snippets
in the Code Snippets Manager, and errors on importing snippets.
The folder Windows directs me to when I open My Documents from my user folder is D:\Personal\
, and I want the code snippets there too:
D:\Personal\Visual Studio 2012\Code Snippets\Visual C#\My Code Snippets
If necessary, I wouldn't mind moving the whole Visual Studio 2012 subfolder. I just can't find out how to set that in Visual Studio.
The UI doesn't make it completely obvious what the buttons are for, but this can actually be done in two simple steps:
Step 1. In Code Snippets Manager, select the folder that points to the disk location you no longer use, and click Remove:
Step 2. Click Add...
...and select your new folder:
That's it! Your new folder is now active in Code Snippets Manager.
Code Snippet folders don't seem to be directly editable in the Visual Studio IDE (that I could find). They are stored as registry entries, so you have to edit these settings directly.
For Visual Studio 2012 the registry settings are located in:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\Languages\CodeExpansions\Visual C#\Paths
The value is called 'Microsoft Visual CSharp', and lists all the different folders separated by semicolons:
%InstallRoot%\VC#\Snippets\%LCID%\Visual C#\;%InstallRoot%\VC#\Snippets\%LCID%\Refactoring\;%MyDocs%\Code Snippets\Visual C#\My Code Snippets\
The quick fix for the snippets would be to provide the full path in place of the %MyDocs% setting.
I couldn't find a reference to how %MyDocs% is defined, but I suspect it's the "Projects Location" setting:
Tools -> Options -> Projects and Solutions/General
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With