Wednesday, September 5, 2018

c# - Including files in an application using XNA



I'm making a game and I need to load some text files to create levels. After much frustration in trying to get them to work I placed the files in the debug folder of my project (I think this is a bad idea but I didn't really know how else to get the StreamReader to work).


The problem is that this means I can't get the project to run when I publish it because I don't know what to do with the text files. Where have I gone wrong and what can I do about it?



Answer



I can't verfiy this right now (no XNA installed), but I'm pretty sure the following should work:



  • Add the text file to your project.

  • Open the file's properties (within VS) and set the following values:

    • Build Action: Content

    • Copy to Output Directory: Copy if newer (or Copy always)





Then open the project properties, select the "Publish" tab and click on "Application Files...". In the new window you should see your text file being listed and you're able to change it's group or status (default one should be fine).


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...