Delete or Restore Files and Folders

Before you delete an item:

  • Caution Before you delete a file, look for a check mark icon TFSC Checked-Out Status Icon, which indicates pending edits in the file . If there are pending edits, you should view them (open the shortcut menu for the file and choose Compare) and make sure that you do not need them. If you think you might need the edits in the future, consider checking in the file before you delete it.

  • Caution icon If you delete a folder, the system will pend delete actions for any folders and files that it contains.

  • Caution icon If you delete a file on which other files have dependencies, the system will automatically pend delete actions for those files. For example, if you delete a form file, the code and resource file will also be pended for deletion.

To delete an item

  1. In either Solution Explorer or Source Control Explorer, browse to the folder or file that you want to delete.

  2. Select the items that you want to delete, open their shortcut menu, and choose Delete.

    Tip Tip

    If you are deleting a file from Solution Explorer, the following warning message may appear: <file name> will be deleted permanently. The file deletion will not be implemented on the server until you actually check in this change. Also, if the file has been checked in to version control, then you can recover the file. Choose OK if you want to proceed with deleting the file.

  3. When you are ready, check in your changes.

If you have not yet checked in your delete change, in Solution Explorer, the Pending Changes page, or Source Control Explorer, select the items, open their shortcut menu and choose Undo or Undo Pending Changes.

If you or one of your teammates has checked in a delete change to the server, you can restore the item as long as no one on your team has destroyed it.

To restore an item deleted from the server

  1. From the menu bar choose Tools, Options.

  2. On the Options dialog box, navigate to Source Control, Visual Studio Team Foundation Server.

  3. Select Show deleted items in the Source Control Explorer, and then choose OK.

  4. From the menu bar choose View, Other Windows, Source Control Explorer.

  5. In Source Control Explorer, navigate to the folder that contains the item you want to restore.

  6. Open the item’s shortcut menu and then choose Undelete.

From time to time you may need to restore an item you have deleted outside Visual Studio (possibly by accident). The method you use to restore such an item depends on whether you are using a local or a server workspace. See Decide Between Using a Local or a Server Workspace.

When you use a local workspace, Visual Studio detects and enables you to resolve changes you have made outside the system.

To use a local workspace to restore an item you deleted outside Visual Studio

  1. In Team Explorer, choose Home icon Home, and then choose Pending Changes.

  2. In the Excluded Changes section, choose the Detected changes link.

  3. In the Promote Candidate Changes dialog box, select an item for which delete appears in the Change column, open its shortcut menu, and choose Restore this item.

When you accidentally delete an item outside Visual Studio and you are using a server workspace, when you try to open the item in Visual Studio you may see an error message such as: TF10187: Could not open document file name The system cannot find the file specified.. You can restore the item by getting it from the server.

To use a server workspace to restore an item you deleted outside Visual Studio

  1. In Source Control Explorer, browse to the folder that contains the deleted items.

  2. Open the shortcut menu of the folder and choose Get Specific Version.

  3. On the Get dialog box, select Overwrite all files even if the local version matches the specified version.

    Choose Get.

Tip Tip

You can also use the tf get /force command.