Copy files during build
I have some text files that my program needs to load. The program will look for these files in the executable directory. Currently these files files reside in the project directory (and are part of the project).
Is there a way to tell visual studio to put these files in the bin/debug (or bin/release) directory as part of t开发者_Python百科he building process?As Conrad Frix explained, build events is one solution.
However, if you do not want to mess around with CMD macros, you might want to simply add the text files to your project:
- For every text file, open its properties (right-click in the Solution Explorer and select Properties).
- In the Build Action property, specify Content.
- In the Copy to Output Directory property, either select Copy Always or Copy if Newer.
If you generate setup projects in Visual Studio, and you want to include the text files, you can then simply add the Content files of the given project and the build process will package them along with your executable.
Try using build events
You can use $(TargetDir) macro which will go to bin/release or bin/debug depending on which you are doing. Here's the compete list of macros
for example Copy "$(ProjectDir)*.txt" "$(TargetDir)"
would copy all the txt files from your project directory to the target directory
Sure. Use a post-build event, configured in the project properties window.
精彩评论