visual-studio 从 Visual Studio 文档缓存中恢复文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/897956/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 10:32:18  来源:igfitidea点击:

Recovering file from the Visual Studio document cache?

visual-studiorecoveryfile-recovery

提问by EightyOne Unite

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!

我刚刚丢失了一些代码。我需要将几个方法从一个类移动到另一个类,所以我点击了保存,剪切了方法,VS 崩溃了。现在看来保存是在剪切之后发生的,因为代码已经在没有这些方法的情况下保存了,但是代码不在我的剪贴板上。所以我没有代码,也没有简单的方法来找回它!

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.

我知道 Visual Studio 会保留一个文档缓存,在显示恢复文件对话框时使用该缓存,但在 VS 启动备份时未显示。我希望我的课程有一个版本,代码还在那里,所以我不必重新开始,但我不知道去哪里找。

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

谁能告诉我 VS 将这些文件保存在磁盘上的什么位置?

Really appreciate ANY help you can offer.

非常感谢您可以提供的任何帮助。

回答by EightyOne Unite

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

排序了。这些恢复文件位于@MyDocuments\Visual Studio X\Backup Files\Project Name...

回答by CAD bloke

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

Visual Studio 2019.4.1 中有我的备份文件%localappdata%\Microsoft\VisualStudio\BackupFiles- MyDocuments 树中的文件夹是空的。

回答by RB.

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

如果您已将代码编译为 DLL,则可以使用 ILSpy 或 Reflector 将其反编译回代码。

回答by aradil

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.

我来到这里寻找同一问题的答案,但这些都没有帮助 - 话虽如此,在 Visual Studio 2010 中删除的文件最终会进入 Windows 回收站。

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

这是另一篇谈论同一件事的帖子:如何从 Visual Studio 2010 恢复已删除的项目?

回答by fahran

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

对于 Linux,位置似乎是 ~/.config/Code/Backups/

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

(在这里找到信息:https: //github.com/Microsoft/vscode/issues/3884

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

祝您恢复文件好运,未来的旅行者!我走运了!

回答by Jeff Moser

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.

它现在对您没有帮助,但您可能想要安装ClipX,这有助于在剪贴板上保留尽可能多的项目。它在崩溃发生时帮助了我,但不久前剪贴板上有一个版本。

回答by redditmerc

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

这是 VS 中的一个已知错误,并且一直被 Microsoft 忽略。结果我失去了一整天的工作。对我有用的解决方案是将我的项目移动到 GoogleDrive 同步文件夹。现在,每次我保存文件时,Google Drive 都会将副本同步到云端。随着对 Git 的定期提交,我永远不必放松工作.. 叹息