I have an issue while trying to load a font file with the extension ".xnb" and I am receiving following error:
Error loading "SpriteFont1". File not found.
For following code:
public static Dictionary<string, T> LoadListContent<T>(this ContentManager contentManager, string contentFolder)
{
DirectoryInfo dir = new DirectoryInfo(contentManager.RootDirectory + "/" + contentFolder);
if (!dir.Exists)
throw new DirectoryNotFoundException();
Dictionary<String, T> result = new Dictionary<String, T>();
FileInfo[] files = dir.GetFiles("*.*");
foreach (FileInfo file in files)
{
string key = Path.GetFileNameWithoutExtension(file.Name);
result[key] = contentManager.Load<T>(key);
}
return result;
}
The file is actually there and I am getting here FileInfo[] files = dir.GetFiles("*.*");
one file which is present in the folder.
I am using the function like this:
fontList = ContentLoader.LoadListContent<SpriteFont>(Content, "Fonts");
Is there something which I have overlooked?
key
? \$\endgroup\$"SpriteFont1.xnb"
you may need to strip the extension? I forget how XNA content pipeline works. \$\endgroup\$