C# 使用 Visual Studio 2012 恢复删除文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14464815/
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-08-10 11:53:38  来源:igfitidea点击:

Restoring delete files with visual studio 2012

c#asp.net.netasp.net-mvcasp.net-mvc-4

提问by Guilherme Longo

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

我不小心删除了我的项目的一部分,认为我在一个临时文件夹中。它是一个 asp.net-mvc 4 应用程序。

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

我没有 tfs 或任何其他程序监视我的文件系统。

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

我刚刚发布了我的应用程序。我只剩下一堆编译过的文件、js、css 和图像。

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.

是否有来自 Microsoft 的任何工具可以执行逆向工程,或者 VS2012 是否跟踪文件以便我可以恢复它。

采纳答案by Andrzej Gis

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.

在 Visual Studio 中删除的文件会转到 Windows 回收站。除非您清除它,否则您的文件应该仍然存在。只需恢复它们,然后将它们作为现有项目添加到您的项目中。您还可以通过解决方案资源管理器拖放它们。

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.

该文件将显示在那里,呈灰色(如果它只是从您的项目中删除 - 而不是您的磁盘驱动器)。然后您可以右键单击它,并将其添加回 ptoject。如果没有,请尝试第一种方法。

回答by Alan

  • 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 DownloadMaybe 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

  • 如果您启用了 Visual Studio 中已删除的文件,它应该最终进入回收站。如果它没有被清除,你可以恢复它。

    • 当您删除文件时,没有真正“删除”文件。它通常被标记为已删除,但仍然可以通过工具轻松恢复。一个这样的工具是由一家名为 AccessData 的公司制造的,该公司生产名为 Forensic Toolkit 的取证调查软件。他们有一个名为 FTK Imager 的程序,它可以创建驱动器或文件夹的映像,甚至向您显示可以恢复的已删除文件。他们软件的这部分是免费的。FTK Imager 下载也许试一试。

    • 最后,学习使用 subversion 或其他版本控制软件(git、tfs)这样以后就不会发生这种情况并备份你的东西

回答by Shaun Grech

  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
  1. 在“Windows 文件资源管理器”中打开已删除项目的文件夹/解决方案
  2. 按 Ctrl+z(撤消)。这将指示 Windows 撤消对文件夹的最后操作
  3. 再次转到 Visual Studio 解决方案
  4. 单击解决方案资源管理器上的“显示所有文件”图标
  5. 点击刷新
  6. 再次包含文件

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/

附注。使用版本控制系统总是更安全,以确保您不仅可以检索文件本身,还可以检索任何先前签入的状态。http://www.incredible-web.com/blog/revision-control-systems/

回答by PK-1825

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

抱歉,我在 Visual Studio 2015 中进行了解释,但选项是相同的,只需按照我的步骤进行即可。

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

步骤 1:打开解决方案资源管理器,右键单击您的项目,然后单击在文件资源管理器中打开文件夹。

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

第 2 步:打开文件资源管理器后按“Ctrl+z”键,这将撤消已删除的文件。

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

第 3 步:返回 Visual Studio,在解决方案资源管理器中按刷新图标,您会在虚线框中找到已删除的文件。 在此处输入图片说明

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

第 4 步:右键单击 Dotted 文件并选择选项包含在项目中。 在此处输入图片说明

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

就是这样。现在您删除的文件包含在项目中。

回答by JBennett

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.

Windows 操作系统会在应用 Windows 更新时创建还原点。如果您损坏了代码模块,就像我今天所做的那样,您可以从 Windows 资源管理器中右键单击它并选择“恢复以前的版本”。相同的选项在文件夹级别可用。

回答by SedatD

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

转到 Visual Studio 解决方案单击解决方案资源管理器上的“显示所有文件”图标单击刷新再次包含文件

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

您可以访问:Remove git mapping in Visual Studio 2015

回答by Baqer Naqvi

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.

解决方案中只有一个项目,我不小心删除了它。好在我在早期阶段就意识到了这一点,当我尝试关闭解决方案时,visual studio 要求我保存解决方案文件。我说不,当我重新加载该解决方案时,项目就在那里。

回答by luno

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

  1. 右键单击您的项目;

  2. 单击“在文件资源管理器中打开文件夹”;

  3. 打开你的项目文件夹;

  4. 一旦项目文件夹打开,只需执行“ctrl + z”。

回答by vijay

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)

  • 步骤 1:转到回收站并恢复已删除的项目。

  • 第 2 步:在 Visual Studio 中,右键单击项目,然后单击添加 > 现有项目(您可以在此处添加已删除的项目)

回答by Md. Shoriful Islam

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

只需进入回收站并按恢复即可。您将在软件文件的文件资源管理器中找到已删除的文件。