2014-09-27 52 views
0

我是XNA游戏开发的新手,我遇到了即使在互联网上搜索也无法解决的问题。我想加载我的模型,但每次它给我这个异常:ContentLoadException未处理。这里是我的代码:加载时出错。无法打开文件

Model model = Content.Load<Model>(@"\Models\hero"); // and file is in fbx format 

这是我的解决方案的截图 enter image description here

+0

您是否设置了RootDirectory? 'Content.RootDirectory =“Content”;' – 2014-09-27 19:25:26

+0

@DavorMlinaric是的 – 2014-09-27 19:26:46

+0

您可以显示内容文件夹结构的图片吗? – 2014-09-28 08:51:18

回答

1

试试这个:

Model model = Content.Load<Model>(".\\Models\\hero"); 

你正在做什么是完美的罚款。试试吧就是微软在MSDN Examples Section上建议的方式。如果它仍然不起作用,你可以确定你的部分有问题。尝试将模型置于同一目录中,以便你可以:

Model model = Content.Load<Model>("hero"); 

如果这仍然无法正常工作,你知道问题出在别的地方。

+0

谢谢你编译,但是没有显示我的模型 – 2014-09-28 12:38:31