September 28, 2013

Copy files to Output in Visual C++

Problem:
- How to Copy a image file in Debug folder?
- How to make a image file output to the Debug or Release directory when compiling
- I want to put a image file under the project root path
- How to configure the project to let it copy the image file to output dir when compiling
- How to automatic copy files to output during application building ...

Solution:
I have a perfect solution. Trust me and come step by step with me.
I do this on Visual Studio 2012, VC++ 11 :-)

1- include the file (or files) to your project.
PS: if you have your the file(s) in project exclude, save project and include it again.

2- Close your Visual Studio and open the project file in any txet editor like notepad or Notepad++

3- Find your file(s) name in project file. It's a None element. Change it like example

BEFORE: 
    <None Include="xyz.ext" />



AFTER:
  <Content Include="xyz.ext">    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  </Content>




1 comment:

Anonymous said...

Took me hours to come across this but this is exactly what i have been looking for for the past few months!