The Move to Another Folder refactorings helps you move one or several types to file(s) in other folder. All necessary directives are moved with the type(s). All using directives that are no longer necessary are removed from the original file.
- Place the caret at the name of a class or interface, etc. in the editor or select it in the Class View window or in the Object Browser window.
Do one of the following:
- On the main menu, choose ReSharper | Refactor | Move.
- Choose Refactor | Move on the context menu.
- Press F6Ctrl+R,O.
- In the Move drop-down list, click Move to Folder. The Move to Folder dialog box opens.
Specify the folder where the chosen type(s) should be moved.
To specify an existing folder, use the Target folder drop-down list.
To create a new folder and move the chosen type(s) there:
- specify the location where the folder should be created, using the Target folder drop-down list
- type \[folder name]
- click Create this folder
Click Preserve hierarchy of folders and file names to leave the structure of folders
"as is" during the refactoring.
Click Put classes into separate files to put each type into a separate file with the appropriate name.
- Select the Fix namespaces check box to adjust namespaces according to the new location automatically.
- Select the Allow change internal visibility to public when it is required check box to change the visibility of an internal type when it is moved to another project.
- All types that can be moved are displayed in the text area. Select appropriate check boxes nearby the types to move them.
- Click Next. If no conflicts are found, ReSharper performs the refactoring immediately. Otherwise, resolve conflicts.
TipWhen you undo this action, be aware that content is deleted from the newly created file, but the file itself is preserved in project.
At the example below, the IActionCollection interface is moved to the Action folder that exists.
After applying the refactoring the IActionCollection.cs file is created.