ReSharper Web Help

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.

To move a type to another folder
  1. 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.
  2. Do one of the following:
    • On the main menu, choose ReSharper | Refactor | Move.
    • Choose Refactor | Move on the context menu.
    • Press F6Ctrl+R,O.
    The Move drop-down list is displayed.
  3. In the Move drop-down list, click Move to Folder. The Move to Folder dialog box opens.
  4. 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
  5. 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.
  6. Select the Fix namespaces check box to adjust namespaces according to the new location automatically.
  7. 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.
  8. All types that can be moved are displayed in the text area. Select appropriate check boxes nearby the types to move them.
  9. Click Next. If no conflicts are found, ReSharper performs the refactoring immediately. Otherwise, resolve conflicts.

Tip

When 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.

Refactorings__Move__Type_to_Folder

After applying the refactoring the IActionCollection.cs file is created.


This feature is supported in the following languages/technologies:

C# VB.NET HTML ASPX Razor JavaScript TypeScript CSS XML XAML RESX Build Scripts
feature_available feature_available

Tip

The instructions and examples given here address the use of the feature in C#. For details specific to other languages, see the corresponding topics in the ReSharper by Language section.

See Also

Procedures: