I just got an e-mail referring to my Code Snippets – the whole enchilada blog post. The question was how you can add a Code Snippets path which is located on a network drive.
Here is how it works:
- Open up regedit.exe
- Go to HKEY_LOCAL_MACHINESOFTWAREMicrosoftVisualStudio8.0LanguagesCodeExpansionsCSharpPaths
- Edit the Microsoft Visual CSharp entry and add the desired path to where the Code Snippets are located separated by a semicolon.
You can either use a mapped network drive or use the network path directly.
You can of course use a .reg file to import the new path. Here is an example for that:
Windows Registry Editor Version 5.00
"Microsoft Visual CSharp"="%InstallRoot%\VC#\Snippets\%LCID%\Visual C#\;%InstallRoot%\VC#\Snippets\%LCID%\Refactoring\;%MyDocs%\Code Snippets\Visual C#\My Code Snippets;<my new Snippets path>"
Replace the <my new Snippets path> placeholder with your desired path and save this to a file with the .reg extension. Remember to double the number of backslashes for escaping purposes. So for a network folder like \MyServerMySnippetsFolder you have to use \\MyServer\MySnippetsFolder in the .reg file.
After doing so, every Code Snippet located in the added folder will automagically be added to the list of available Code Snippets. You don’t even have to restart Visual Studio after adding new Code Snippets. You can also add subfolders and place your Snippets there. The subfolders will also be added automaticaly.
Here comes the “but” as nearly always: The strange thing is, that you have to add this path to the “LOCAL_MACHINE” section to the registry. Adding the same path to the “CURRENT_USER” section had no effect.