Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a folder to bin (debug/release) in post-build

Tags:

c#

.net

I have a folder in my project. And inside that folder are files that my program is going to read from at run-time (i.e. most important one of them). So if the folder name is "xyxyxy" and if I am looking for the file "zzz.xml" in that folder I can access that file by

if (File.Exists(Environment.CurrentDirectory + "/xyxyxy/zzz.xml"))
    MessageBox.Show("File found!");
else
    MessageBox.Show("Not found!");

How can add this entire folder to the bin folder (both in debug and release)?

like image 387
disasterkid Avatar asked Dec 19 '22 10:12

disasterkid


2 Answers

In Visual Studio, for the file you want to be copied to folders under bin, mark the Copy to Output Directory property of the file as Copy always. That should output the file, along with the folder structure to wherever the binaries are emitted.

like image 176
Vikas Gupta Avatar answered Dec 21 '22 22:12

Vikas Gupta


You can simply add a post-build step for that in the project that contains the executable you are running. You can use the macro's to determine the exact directory that your dll's/exe are copied to to create your directory and files.

like image 26
Wim.van.Gool Avatar answered Dec 22 '22 00:12

Wim.van.Gool