Move the list of source files with classes inside to another folder and automatically change the namespace
Let's say I have 100 winforms in my Forms folder. All form classes belong to the ProjectName.Forms namespace. I want to move all these forms to the WinForms folder, and I want their namespace to change to ProjectName.WinForms.
Is there a way to do this automatically without manually changing the namespace of each form? I have Resharper but couldn't find any options that could help.
Thanks in advance.
a source to share
To do this, you can use the Visual Studio Replace In Files command. In the menu Edit → Find and Replace → Replace in Files.
Next to the Look in dropdown, you have a builder button. By clicking on this, you will see a window where you can specify the folder you want to look at.
Here is the screening:
alt text http://img148.imageshack.us/img148/5472/replaceinfiles.png
a source to share
For these types of scripts, I usually use shell script magic (you'll need cygwin and / or Perl or the like). Sort of:
for i in *; do perl -pi -e 's / ProjectName.Forms / ProjectName.WinForms / g' $ i; done
I suppose VS probably has some kind of advanced search and replaces the built in functionality.
a source to share
You can use Replace in Files to restrict the replacement to a specific folder and match whole words to avoid unwanted replacements.
First, replace all "ProjectName.Forms namespace" with "ProjectName.WinForms namespace" and then, if you have dependent code, replace "using ProjectName.Forms;" with 'using ProjectName.WinForms;' in that.
(Edit: assumed C #)
a source to share