Sign in to follow this  

Packing Text Files in XNA 3.0

This topic is 3288 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a quick question about packing files into an XNA 3.0 build. I have a bunch of text files that I use for level data information and was wondering if there was a way to pack them into the build process. Kind of like the way that image and sound data are packed into the build. Currently I have sounds packed up so that when I build the project the audio is put into the content\audio directory. Is there a way to add text files to the build so that when the project is built it goes into a folder like content\levels? Thanks in advance.

Share this post


Link to post
Share on other sites
Well the easy thing to do is to just add them to your Content project, set them to NOT compile, and then set them to be copied to the output folder on build. This will simply copy the file to Content\Levels (or whatever you named the folder in your Content project).

If you wanted to get fancier, you could make a very simply Content Importer and Processor that simply loads the text file as a string and saves it as a .xnb file. This would give you content compression, and would also let you use the ContentManager to load the level data.

Share this post


Link to post
Share on other sites
Thanks MJP.

I think I tried that last night but when I tried to compile I got an error that said something about it needing an appropriate content importer. so I tried messing around with that but didn't get anywhere. I will try messing around with it again tonight. If it is that easy I should be able to figure it out. I will try to copy down the exact error I am getting when I compile.

Thanks again

Share this post


Link to post
Share on other sites
Yeah you need to set the Content not to compile the file by setting the "Build Action" property to "None" (sorry I couldn't remember the property name earlier when I was at work). Then set the "Copy To Output Directory" property to "Always".

Share this post


Link to post
Share on other sites
Yeah thanks, that did work. I did exactly that when got hope and it worked like a charm!

Share this post


Link to post
Share on other sites

This topic is 3288 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this