34

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.

Kilian Stinson
  • 2,376
  • 28
  • 33
Guilherme Longo
  • 2,278
  • 7
  • 44
  • 64

12 Answers12

105

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.

user1857492
  • 697
  • 1
  • 7
  • 22
Andrzej Gis
  • 13,706
  • 14
  • 86
  • 130
  • 2
    Good answer for VS 2015 as well. – froggythefrog Mar 13 '16 at 21:47
  • Holy crap I had no idea. I just stumbled across this by accident, this would've been so useful to know several times in the past! Thanks – Jordan Wallwork Oct 06 '16 at 21:19
  • 2
    A whole afternoon of uncommited work saved. Never been so happy about a feature. – monoceres Oct 18 '16 at 13:25
  • 1
    This solution didn't work for me as the project wasn't saved on the local directory but a mapped drive. If you can't find it in recycle bin or windows explorer you may just have do down the backup recovery route – notidaho Nov 15 '18 at 11:43
30
  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/

Shaun Grech
  • 351
  • 3
  • 5
4

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

luno
  • 51
  • 2
1
  • 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

Alan
  • 7,875
  • 1
  • 28
  • 48
1

Sorry i'm explaining in Visual Studio 2015, but options are same, just go through my steps.

Step 1: Open solution Explorer, right click on your project then Click on Open Folder In File Explorer.

Step 2: After open file Explorer Press "Ctrl+z" keys, this will have undo your deleted files.

Step 3: come back to visual studio, press refresh icon in solution explorer, you would have find your deleted files within dotted box. enter image description here

Step 4: Right click on the Dotted file and select Option include in project. enter image description here

that's it. now your deleted files are included in project.

PK-1825
  • 1,431
  • 19
  • 39
1

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.

CubeJockey
  • 2,209
  • 8
  • 24
  • 31
JBennett
  • 11
  • 1
0

Go to the Visual Studio solution Click 'Show All files' icon on Solutions explorer Click Refresh Include the files again

and you can visit: Remove git mapping in Visual Studio 2015

Community
  • 1
  • 1
SedatD
  • 1
  • 4
0

There was only one project in the solution & I accidentally removed it. Good thing was I realized it on earlier stage & when I tried to close the solution, visual studio asked me to save the solution file. I said no & when i reloaded that solution, project was there.

Baqer Naqvi
  • 6,011
  • 3
  • 50
  • 68
0

Yeah, it is easy to restore.

  • Step 1: Go to recycle bin and restore the deleted items.

  • Step 2: In Visual Studio ,right click on the project and click add > Existing Items (Here you can add the deleted items)

trungduc
  • 11,926
  • 4
  • 31
  • 55
vijay
  • 1
0

On the top bar menu, select file then on the drop-down select Revert file The deleted file will be restored.

TrevorDeTutor
  • 683
  • 6
  • 11
0

Go to Source Contror in the left side of visual studio code editor and click on it , you will see the deleted files , mouse hover on file and click on Discard Change. Your file will restore . Click here you will see the image

BDL
  • 21,052
  • 22
  • 49
  • 55
Siraj Ali
  • 526
  • 6
  • 13
-2

Just go to Recycle Bin and press the restore.you will find the deleted file in the file explorer in the software file.