Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XNA C# Problem reading directory content

Tags:

c#

xna

I've started developing of card game with XNA but I had problems reading all the cards inside the Cards directory which is inside a Content.

I've tried following code:

string[] nomeCartas = Directory.GetFiles(@"Cards");

But with that I retrieved an error saying it could not be possible to find part of the path:

Não foi possível encontrar uma parte do caminho 'C:\Users\Serafim\Documents\Visual Studio 2010\Projects\JogoSuecaOnline\JogoSuecaOnline\JogoSuecaOnline\bin\x86\Debug\Cards\'.

I checked that path and it's wrong, the correct path should be:

C:\Users\Serafim\Documents\Visual Studio 2010\Projects\JogoSuecaOnline\JogoSuecaOnline\JogoSuecaOnline\bin\x86\Debug\Content\Cards\

Is there any other way to read the Directory Content with XNA or how can I fix this?

like image 816
Luis Avatar asked Dec 28 '22 22:12

Luis


2 Answers

string[] nomeCartas = Directory.GetFiles( Content.RootDirectory + "\\Cards" );
like image 183
borrillis Avatar answered Jan 10 '23 20:01

borrillis


Try:

Directory.GetFiles(@"Content\Cards");
like image 37
Jackson Pope Avatar answered Jan 10 '23 19:01

Jackson Pope