将文件复制到在编译时应用程序文件夹

将文件复制到在编译时应用程序文件夹

本文介绍了将文件复制到在编译时应用程序文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一些文件,我想从我的项目复制到上编制的 \\ BIN \\调试\\ 文件夹,然后好像我得把它们放进该项目的根。将它们放入一个子文件夹在他们看来复制到 \\ BIN \\调试\\ 文件夹中它们存储在相同的结构。

If I have some files I want to copy from my project into the .\bin\debug\ folder on compilation, then it seems I have to put them into the root of the project. Putting them into a subfolder seems to copy them into the .\bin\debug\ folder in the same structure they're stored in.

有什么办法避免这种情况?

Is there any way to avoid this?

只是要清楚:如果我有一个 MyFirstConfigFile.txt MySecondConfigFile.txt ConfigFiles 文件夹,我把他们的复制到输出的是复制... 的,那么他们出现在 \\ BIN \\调试\\ ConfigFiles \\ 文件夹中。我希望他们能够出现在 \\ BIN \\调试\\ 文件夹中。

Just to be clear: if I have a MyFirstConfigFile.txt and MySecondConfigFile.txt in a ConfigFiles folder and I set their Copy to Output to be Copy..., then they appear in the .\bin\debug\ConfigFiles\ folder. I want them to appear in the .\bin\debug\ folder.

推荐答案

您可以用一个后生成事件做到这一点。文件的文件设置为对编译不采取行动,那么在宏观拷贝到你想要的目录。

You could do this with a post build event. Set the files to no action on compile, then in the macro copy the files to the directory you want.

下面是一个后生成宏,我认为会通过复制在一个叫做配置到根build文件夹目录下的所有文件的工作:

Here's a post build Macro that I think will work by copying all files in a directory called Configuration to the root build folder:

copy $(ProjectDir)Configuration\* $(ProjectDir)$(OutDir)

这篇关于将文件复制到在编译时应用程序文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 16:59