ReSharper 2016.3 Help

Move to Folder refactoring

ReSharper | Refactor | Move…

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

Note that 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

To move types or files to another folder

  1. Select types that you want to move in one of the following ways:
    • In the editor, set 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 Ctrl+Shift+R and then choose Move To Folder
    • Right-click and choose Refactor | Move To Folder in the context menu.
    • Choose ReSharper | Refactor | Move… in 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, e.g. 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 check box.
  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 check boxes 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.

This feature is supported in the following languages/technologies:

C# VB.NET C++ HTML ASPX Razor JavaScript TypeScript CSS XML XAML RESX Build Scripts Protobuf JSON
/help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg

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

See Also


Last modified: 19 January 2017