【问题标题】:DirectX Windows 8.1 fstream won't load fileDirectX Windows 8.1 fstream 不会加载文件
【发布时间】:2015-02-06 22:00:06
【问题描述】:

我正在构建一个 Windows 8.1 DirectX 应用程序并尝试在外部加载以存储级别数据。

目前相关代码为(该方法在AssetHandler构造函数中调用):

void AssetHandler::LoadLevelsData()
{ 
  unsigned int i = 0;
  std::string lineData;

  this->currentFile.open("Assets/reg.txt");
  //Below statement here purely to check if the blasted thing is opening
  if (this->currentFile.is_open())
  {

    i++;
  }
  while (std::getline(this->currentFile, lineData))
  {
    levels[i] = lineData;
    i++;
  }
  currentFile.close();
}

我遇到的问题是文件似乎没有打开。我试过了:

  • 使用完整路径
  • 在初始化列表中打开文件
  • 断点显示它正在跳过 if 和 while

我发现一些信息说 DirectX 对处理外部文件有限制,但它没有具体说明这些是什么。

【问题讨论】:

  • 这个问题似乎与 DirectX 无关。
  • 我只是不想排除任何可能。我的印象是这个问题可能特定于开发 DirectX 应用程序。

标签: c++11 directx-11


【解决方案1】:

项目类型设置为“不参与构建”。将此值设置为“文本”即可解决问题。

【讨论】:

  • 这意味着你得到的错误是它不存在。当 is_open 返回 false 时,您应该能够调用 errnoGetLastError() 以了解发生了什么。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-06-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多