Rafael Perrella
Rafael Perrella

Reputation: 76

How to recover files from Visual Studio Code?

I've been writing a .cpp file for two entire days now. It was just that one file, for an university project. So, I finally finished the code, and I decided to see if I could make a C interface to use it in C (generating the .o files with g++ and then linking them together to use with gcc). So I executed a g++ command which removed the .cpp!! (Cool, ahn?!)

It was opened in the VS Code, but the editor closed the file as soon as it was deleted (omg why?! worst design decision ever but whatever). Is there any way to recover the file? It's not in the recycle bin.

Upvotes: 3

Views: 11292

Answers (2)

Freigus
Freigus

Reputation: 51

Another option would be to use Timeline feature:

  1. Go to Explorer -> Timeline.
  2. In upper right corner click "More Actions".
  3. Open "Local History: Find Entry to Restore..."
  4. Enter required filename or part of it's relative path.

AFAIK it saves versions every time file is saved (or for some other actions) in VSCode. So it might not work for files that you haven't edited.

Upvotes: 3

Raj K
Raj K

Reputation: 325

I was recently using VS Code server (i.e., SSH into remote machine) when I "Permanently Deleted" the wrong file. I was able to find it in /home/{username}/.vscode-server/data/User/History under the temporary files & folders by looking at the most recently used items. Hope this helps someone else!

Upvotes: 2

Related Questions