Reputation: 2279
In MS Visual Studio 2008, it's very easy to copy non-C# files, such as an XML file, in a C# project to the output folder. Just add the file to the project, select it in Solution Explorer, then select Properties, and there's a choice named "Copy". You can choose "Do not copy", "Copy", and "Copy If Newer".
But in C++, it's not so easy, probably because there was never anything similar in earlier versions of Microsoft's compilers. The only option I have is to add a post-build event with an old-fashioned DOS command line command to copy the file to the target path. There's no way I know of to compare the dates on the input and target files, if the target file already exists.
I tried adding the files to my C++ project in the same was as I would in a C# project. The options for the files included a custom build step. I tried putting the copy command in there, but it didn't work.
Is there some way I don't know about to get the same result as I get in C#: a nice, clean, easy way to specify that a file get copied from the project folder to the output folder if it is newer than the file in the output folder?
Thanks very much!
RobR
Upvotes: 0
Views: 322
Reputation: 2279
xcopy "source file name" "destination" /D /Y should do it. When tested in a command window, backslashes instead of forward slashes were required.
Upvotes: 0
Reputation: 6905
In your post-build event, you could use robocopy instead of the basic copy command (it is more intelligent, can somewhat manage file modification dates e.g. robocopy /xo <...>
)
see http://technet.microsoft.com/en-us/library/cc733145%28v=WS.10%29.aspx
Upvotes: 1