VS PostBuild Event - Copy file if it exists

大城市里の小女人 提交于 2019-12-21 07:09:30

问题


Is there a simple way to copy a file in a post-build event for a Visual Studio project, but only if the file exists? (i.e. don't fail the build if the file doesn't exist)

I've tried some options using xcopy. But I feel so stupid - I can't seem to get my head around what switches I might need with xcopy.


回答1:


Use "IF" command:

IF EXIST file.txt xcopy file.txt [destination_folder]\ /Y



回答2:


Also without the IF EXIST but using the /U option of XCOPY

xcopy source_file_name dest_folder /u /y


来源:https://stackoverflow.com/questions/11422555/vs-postbuild-event-copy-file-if-it-exists

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!