41

I've just lost some code. I needed to move a couple of methods from one class to another so i hit save, cut the methods and VS crashed. Now it seems that the save happened after the cut since the code has been saved without those methods but the code isn't on my clipboard. So I'm left without the code and no easy way to get it back!

I know that Visual Studio keeps a document cache which it uses when the recover files dialog is shown but it wasn't shown when VS started back up. I'm hoping that there is a version of my class with the code still in there so i don't have to start again but i don't know where to look.

Can anybody tell me where VS keeps these files on disk?

Really appreciate ANY help you can offer.

12 Answers 12

80

Sorted it. Those recovery files are located @ MyDocuments\Visual Studio X\Backup Files\Project Name...

7
  • 3
    Also nice to know (least with 2010) is that the recovered file & the original file are in the same folder, I just had a corupt 'recovered' file almost lose me 2 days worth of work (yet the original file was actually up to date...)
    – Stephen
    Commented Nov 9, 2011 at 16:30
  • 18
    did you have to enable this feature? my version of this folder is empty. Commented Nov 9, 2012 at 17:40
  • 2
    This option is available in Visual Studio 2017, but not in Visual Studio 2019.
    – Evorlor
    Commented Feb 7, 2020 at 23:24
  • 1
    @BrianSweeney I believe this folder moved in the latest version. This answer below has the correct folder path now: stackoverflow.com/a/59277526/358578
    – pbristow
    Commented Jul 14, 2020 at 18:01
  • Note that the 'X' here is the number of your MVS version. That saved me 1 day job today. Commented Aug 6, 2020 at 14:59
62
+50

Visual Studio 2019.4.1 had my backup files in %localappdata%\Microsoft\VisualStudio\BackupFiles - the folders in the MyDocuments tree were empty.

14
  • 4
    Thanks @CAD bloke, you saved my life. Vs2019 save the file twice, before recover as Original-$datetime$filename.cs and the recovered(which is damaged), then i restored the original file and restored non-committed work..
    – M.Hassan
    Commented Dec 29, 2019 at 23:35
  • 1
    VS2019 did not autorecover this for me and I was able to dive in the tree and find my code. 2 hrs saved!
    – Hucker
    Commented Feb 11, 2020 at 13:14
  • 1
    Thank you, you saved my life. Everytime I allow visual studio to revocer some data for me, it mess things bayound recovery. but this time it currupt several days worth of job, and i couldn't stand it, tried decompiling, searching, hidden files, any thing, and in the end you saved my time. thank you. Commented Apr 25, 2020 at 15:00
  • 2
    Saved me from a heart-attack when a VS backup recovery wiped a really important file clean.. I will forever thank you!
    – Brixster
    Commented May 5, 2020 at 20:23
  • 2
    Man, you saved me from a heart attack! Commented Jul 12, 2020 at 22:30
14

If you have compiled the code into a DLL, then you can use ILSpy, or Reflector to decompile that back into code.

2
  • Yes we can also see obj folder for cached binary files. Commented Dec 29, 2022 at 15:03
  • You sir, are a real hero.
    – Endery
    Commented Sep 28, 2023 at 7:37
8

I came here looking for an answer to the same issue, but none of these things helped -- that being said, in visual studio 2010 deleted files end up in the Windows Recycle bin.

Here's another post talking about the same thing: How do I recover a deleted item from Visual Studio 2010?

2
  • In my case this was the simplest solution that worked... (For VS 2017 as well) Commented Mar 6, 2018 at 17:44
  • You really saved me!
    – GRASBOCK
    Commented Jan 12, 2019 at 15:47
4

It's actually simple. Open Command Pallette in VS code by Typing Ctrl Shift P, Mac I assume cmd Shift P. Then search "local history" you should see revert entry ... then a pop up will show up select the file to revert. You will see the code there.

2
  • 1
    This question is about Visual Studio, not VS Code.
    – ascott18
    Commented Apr 6, 2023 at 19:10
  • I came here looking for vscode help, so thanks! Commented Nov 6, 2023 at 23:43
2

This is a known bug in VS and is being continually ignored by Microsoft. I've lost full day's worth of work as a result. The solution that worked for me was to move my project to a GoogleDrive sync folder. Now every time I save files, Google drive syncs a copy to the cloud. Along with regular commits to Git, I should never have to loose work.. sigh

2

For Linux, the location seems to be ~/.config/Code/Backups/

(found the info here: https://github.com/Microsoft/vscode/issues/3884)

Good luck recovering your files, future travellers! I got lucky!

1
1

It doesn't help you now, but you might want to install ClipX, which helps keep as many items on the clipboard as you'd like. It's helped me in times when the crash happened, but there was a version on the clipboard awhile back.

1

⁠Found my files after searching everywhere... I ended up here: C:\Users[me]\AppData\Roaming\Microsoft\SQL Server Management Studio\18.0_IsoShell\AutoRecoverDat

And so opened that data file which led me to the correct paths for where my files were backed up C:\Users[me][OneDrive]\Documents\Visual Studio 2017\Backup Files\Solution1

What is strange is I went to the above, after checking our new One Drive and seeing nothing, and I did not see my files at the above path. So not sure if I had to open the data file to make them become visible or I just did not notice them when I first checked that path.

0

Running on Ubuntu 18.04, with VS code 1.51.0

My VS Code deleted files are located at: ~/.local/share/Trash/files

To search for your deleted files:

find ~/.local/share/Trash/files -name your_file_name 

Hope my case helped!

0

For those finding this after deleting files and using Visual Studio (2019, professional in my case) and none of the above working, I managed to find some intellisense backups in:

%appdata%\Local\Temp\VSFeedbackIntelliCodeLogs\Suggestions\XXX\output\versions

Where XXXX is the nearest time in which you were working on the deleted files.

One of my missing files was there in it's entirety, another did have some bits missing but it's far better than the alternative.

0

⁠Found my files after searching everywhere... I ended up here: C:\Users[me]\AppData\Roaming\Microsoft\SQL Server Management Studio\18.0_IsoShell\AutoRecoverDat

And so opened that data file which led me to the correct paths for where my files were backed up C:\Users[me][OneDrive]\Documents\Visual Studio 2017\Backup Files\Solution1

Not the answer you're looking for? Browse other questions tagged or ask your own question.