简体   繁体   中英

.NET Core: Copy Arbitrary file like Config.json to Project's Output Directory

I read the json configuration file (./config) in the Program.cs source code, but when I compile and run, the path of the program is at the compiled file location (/Debug/{ProjectName}), so it reports an error. Because it can't find the config.json file. What do I have to do to automatically copy the json file to the compiled folder location at compile time?

Using VS 2017, open Solution Explorer and right click on the config file you want to move.

Go to properties and Set "Copy to OutPut Directory" to value "Copy if newer". Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM