Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a namespace to the default winforms template in visual Visual Studio 2010?

Tags:

namespaces

c#

I frequently work with the System.IO namespace. Is there a way to have that be included with each new project I create?

Thanks

like image 223
JimDel Avatar asked Mar 23 '12 15:03

JimDel


3 Answers

Adding it to the default template might be tricky, I would leave it alone.

You can easily create an empty project, make all sorts of settings and modifications and save it a s a new template (File|Export as template). A lot safer in the long run.

Just make it a habit of starting your new projects from your own custom templates.

If you really want to you can edit the contents of the file that is usually at c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplates\CSharp\Windows\1033\WindowsApplication.zip

like image 167
Henk Holterman Avatar answered Sep 28 '22 16:09

Henk Holterman


Check out Changing the default using directives in Visual Studio.

like image 24
Brian Avatar answered Sep 28 '22 14:09

Brian


The basic answer is to modify the class.zip file located here (for various options):

Visual Studio 2008

For 64 bit:

C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.zip

For 32 bit:

C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.zip Visual Studio 2010

For 64 bit:

C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.zip

For 32 bit:

C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.zip

And then run devenv.exe /installvstemplates in one of the following locations:

Visual Studio 2008 64-bit

cd C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\

32-bit

cd C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\

Visual Studio 2010 64-bit

cd C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\

32-bit

cd C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\

A more complete answer is here and here.

like image 23
N_A Avatar answered Sep 28 '22 16:09

N_A