ReSharper 2023.3 Help

Move to Folder refactoring

This refactoring helps you move one or several types or files to another project or folder anywhere in your solution. If necessary, the refactoring will create the new target folder for you. All imports that the moved type(s) require are fixed in the new location. All imports that are no longer necessary are removed from the original file(s).

Notes:

  • This refactoring is not available for nested types.

  • If you are moving types to another project, there may be missing project references for namespaces used in the moved types. In this case, you will have to add the missing references manually.

Move types or files to another folder

  1. Select types that you want to move in one of the following ways:

    • In the editor, place the caret at the name of a type.

    • Select one or several types and/or files and/or folders in the Solution Explorer.

    • Select a type in the File Structure window.

    • Select one or several types in the Class View.

    • Select a type in the Object Browser.

    • Select a type or folder(s) in the type dependency diagram.

  2. Do one of the following:

    • Press F6 and then choose Move To Folder

    • Press Control+Shift+R and then choose Move To Folder.

    • Right-click and choose Refactor | Move To Folder from the context menu.

    • Choose ReSharper | Refactor | Move… from the main menu.

    The Move To Folder dialog will open.

  3. In the Target folder field, specify the folder where the selected items should be moved:

    • Start typing the name of the target folder or the target project and use the completion suggestions to select it.

    • If the target destination is not valid, for example, other language is used in the target project, or a solution folder is selected, then the red icon appears. This means that you need to change the destination.

    • If you need to create a new folder in the selected destination, type \[folder name] and click Create this folder.

  4. If you move several types, you can select Preserve hierarchy of folders and file names to leave the structure of original files folders "as is" during the refactoring, or select Put classes into separate files to put each type into a separate file with the appropriate name.

  5. The namespace imports in the moved items are fixed automatically according to the new location. If you want to adjust namespaces manually, clear the Fix namespaces checkbox.

  6. Select Allow change internal visibility to public when it is required to change the private, protected and internal visibility restrictions so not to break the existing type usages.

  7. By default, all types from all selected items will be moved. If necessary, you can clear checkboxes for the types that you want to leave in the original location.

  8. To apply the refactoring, click Next.

  9. If no conflicts are found, ReSharper performs the refactoring immediately. Otherwise, it prompts you to resolve conflicts.

ReSharper. Move to Folder refactoring

This feature is supported in the following languages and technologies:

Language: C#

Language: VB.NET

Language: C++

Language: HTML

Language: ASP.NET

Language: Razor

Language: JavaScript

Language: TypeScript

Language: CSS

Language: XML

Language: XAML

Language: Resx

Language: Build Scripts

Language: Protobuf

Language: JSON

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in HTML

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in JavaScript

Feature is available in TypeScript

Feature is not available in CSS

Feature is not available in XML

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

Feature is not available in Protobuf

Feature is not available in JSON

The instructions and examples given here address the use of the feature in C#. For more information about other languages, refer to corresponding topics in the ReSharper by language section.

Last modified: 18 March 2024