在 Visual Studio 2012 中导入现有源文件 [英] Importing an existing source file in Visual Studio 2012

查看:54
本文介绍了在 Visual Studio 2012 中导入现有源文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将教程的源代码添加到现有项目中,并且我希望将该文件从我下载到的桌面上的临时文件复制到项目文件夹中.在解决方案资源管理器中单击源文件"文件夹的上下文会引导我添加->现有项目...菜单,然后我可以添加源文件.但是,它不会复制到项目文件夹中,而是保留在其原始位置.项目只知道它,将其显示在解决方案资源管理器中,并将其视为项目的一部分.

).

此外,您可以将文件直接从资源管理器拖放到 Visual Studio (当它们都是如果您启用了用户帐户控制,则运行在相同的提升级别).要解决 UAC 问题,您也可以以管理员身份运行资源管理器或安装 VSCommands 扩展.

您可以通过右键单击项目或项目文件夹并在上下文菜单中选择粘贴,将一个文件或一组文件复制并粘贴到解决方案资源管理器中.

I want to add the source-code of a tutorial into an existing project, and I want the file to be copied to the project folder from the temporary file on the desktop I downloaded it to. Context clicking on the "Source Files" Folder in the Solution Explorer leads me the Add->Existing Item... menu, and I can then add the source file. However, it is NOT copied into the project folder, but stays in its original location. The project just knows about it, displays it in the Solution Explorer, and considers it part of the project.

This help page on MSDN tells me that in Visual Studio 2010, default behaviour used to consist in copying the file into the project folder, and that one could choose to Add a link instead of physically importing the file into the project directory by choosing "Add Link". However, now I always only get a link, and real physical import into the project folder seems impossible.

I could go through the File Explorer to physically import, but the Solution Explorer doesn't update the new files on the fly, and I would like to do this from within VS.

Is there a way? Is this a bug in VS 2012?

解决方案

Copy in the files using Explorer, then in the solution explorer tick the Show All files option in the button bar of the solution explorer (you might need to select a Project first).

You can now right-click any files not part of the projects and choose Include in Project.

Or use the Add Existing File option.

The reason files are not added automatically to your solution when pasted into the folder using Explorer is because you might not want to have them added.

A neat little trick is to use the "Open In explorer" option:

(though it might be added by the Productivity Power Tools).

Plus, you can Drag&Drop files directly from explorer to the Visual Studio (when they're both running in the same elevation level if you have User Account Control enabled). To fix the UAC issues, you can either run Explorer as administrator too or install the VSCommands extension.

And you can Copy&Paste a file or set of files into the solution explorer by right-clicking a project or project folder and picking Paste on the context menu.

这篇关于在 Visual Studio 2012 中导入现有源文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆