Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to ask, is there way to load in xna all content from folder ?
For example in my content I have:


I want to make something like this

Dictionary<string,Model> models = new ...

foreach(string name in content.getNames("Images"))
    models[name] = content.load<Model>("Images\\" + name);
share|improve this question

There's a great MSDN page about a useful directory access method and someone's asked a similar question on StackOverflow.

Basically, find the files that are in that directory, initialise an array of that size and then iterate through those files, loading in the resources.

share|improve this answer
It's not static, but there is a Content property on the Game class which is commonly used in XNA. – Michael Coleman Jun 16 '11 at 23:25
@Omnion Thanks for the correction -- edited. – Anko Jun 16 '11 at 23:33
Actually the answer that you linked is an extension method for the ContentManager class. So you'd use it as Content.LoadContent<Texture2D>("myFolder"). The Content property on Game is simply an instance of the ContentManager class - you could use any instance you like. (Nothing about this has changed between XNA versions.) – Andrew Russell Jun 17 '11 at 1:22
@Andrew Thank you! I've deleted my false and pointless note. – Anko Jun 17 '11 at 10:53

It's a tutorial about loading content at runtime. It shows how to generate a list automatically by using the content pipeline.

share|improve this answer

You can easily list all the files inside a folder and then load them one by one. By default all content files are stored in a folder right beside your main application so you just need to check for the contents of that direction. You can also use a recursive function if you want to load all files from all the directories. here is a little sample:

string[] files = Directory.GetFiles("content\\Images");
for (int i = 0; i < files.Count(); i++)

notice that when you are asking content system to load a texture, you should drop "content" folder from file name.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.