XNA C # Problem reading directory contents

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

I tried the following code:

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

But with this I got an error stating that it is impossible to find part of the path:

Do caminho National Board of Trade Oversight "C: \ Users \ Seraph \ Documents \ Visual Studio 2010 \ Projects \ JogoSuecaOnline \ JogoSuecaOnline \ JogoSuecaOnline \ Bin \ x86 \ Debug \ cards \".

I checked this path and it is wrong, the correct path should be:

C: \ Users \ Seraphim \ Documents \ Visual Studio 2010 \ Projects \ JogoSuecaOnline \ JogoSuecaOnline \ JogoSuecaOnline \ Bin \ x86 \ Debug \ Content \ Cards \

Is there any other way to read the contents of a directory using XNA or how to fix it?

+4
source share
3 answers

Try:

 Directory.GetFiles(@"Content\Cards"); 
+4
source
 string[] nomeCartas = Directory.GetFiles( Content.RootDirectory + "\\Cards" ); 
+6
source
 string[] nomeCartas = Directory.GetFiles( Path.Combine(Content.RootDirectory, @"Cards"), @"*.xnb"); 
0
source

Source: https://habr.com/ru/post/1347576/


All Articles