Restoring delete files with visual studio 2012

60,581

Solution 1

Files you delete in Visual Studio go to Windows recycle bin. Unless you cleared it, your files should still be there. Just restore them and than add them to your project as existing items. You can also drag and drop them through Solution Explorer.

EDIT:

You can also click the "Show All Files" button in solution explorer.

Highlighted: Show All Files button in Solution Explorer

The file will appear there, grayed out (if it was only removed from your project - not your disk drive). Then you can right-click it, and add it back to the ptoject. If it's not there try the first approach.

Solution 2

  1. Open folder/solution of the deleted items in 'Windows File Explorer'
  2. Press Ctrl+z (undo). This will instruct windows to undo the last actions on the folder
  3. Go to the Visual Studio solution again
  4. Click 'Show All files' icon on Solutions explorer
  5. Click Refresh
  6. Include the files again

PS. Its always safer to use a version control system, to make sure you can retrieve not just the file itself but any previously checked-in state. http://www.incredible-web.com/blog/revision-control-systems/

Solution 3

Try this:

  1. Right click in your project;

  2. click on "Open Folder in File Explorer";

  3. open your project folder;

  4. once the project folder is open just do a "ctrl + z".

Solution 4

Windows OS creates restore points when Windows Updates are applied. If you damaged a code module, like I did today, you might be able to right click on it from Windows Explorer and choose "Restore previous versions". The same option is available at the folder level.

Solution 5

  • Deleted files in visual studio should end up in the recycle bin if you have it enabled. If it has not been cleared out, you can restore it.

    • No file is really "deleted" when you delete it. It is usually marked as deleted but still can easily be restored by tools. One such tool is made by a company called AccessData that makes forensic investigation software called Forensic Toolkit. They have a program called FTK Imager which can create an image of a drive or folder and even show you deleted files which you can restore. This portion of their software is free. FTK Imager Download Maybe give it a try.

    • Lastly, learn to use subversion or other version control software (git, tfs) so this doesn't happen to you in the future and backup your stuff

Share:
60,581
Guilherme Longo
Author by

Guilherme Longo

Updated on July 26, 2020

Comments

  • Guilherme Longo
    Guilherme Longo almost 4 years

    I have accidentally removed part of my project thinking that I was in a temp folder. It is an asp.net-mvc 4 application.

    I don´t have tfs or any other program monitoring my filesystem.

    I had just publish my application. All I have left is a bunch of compiled files, js, css and images.

    Is there any tool from Microsoft that I could perform a reverse engineering with or does VS2012 keep track of files so I could restore it.