从DirectX 11.2应用程序打开或创建文件

Opening or creating a file from a DirectX 11.2 app

本文关键字:创建 文件 应用程序 DirectX      更新时间:2023-10-16

我正试图打开一个.obj文件,该文件包含Blender中球体的顶点和面。问题是,我似乎一辈子都无法打开包含.obj数据的文件。我试着用一种普通的C++方法写入.txt文件,检查应用程序将在哪里创建它,也许还试着把.obj文件放在那个文件夹中。我用来写入.txt文件的代码如下:

std::ofstream myfile("nestotamo.txt");
if (myfile.is_open())
{
    myfile << "This is a line.n";
    myfile << "This is another line.n";
    myfile.close();
}
else DebugPrint("Unable to open file");

我发布的代码不起作用,文件甚至没有创建。我应该从哪里加载.obj文件,为什么我甚至不能创建一个常规的.txt文件来找出应用程序放置它们的位置。

我用来尝试加载数据的代码如下:

   std::wifstream fileIn(path.c_str());
        if (fileIn)
        {
            while (fileIn)
            {
                wchar_t line[64];
                fileIn.getline(line, 64);
                DebugPrint(line);
            }
        }
        else {
            DebugPrint("t The file wasnt loaded...n");
        }

任何帮助都将不胜感激。

我发现在处理文件时不能使用常规c++,因为DirectX在处理这些文件时有一些额外的限制。但是,幸运的是,我发现文件需要在以下文件夹中:

Solution_Namex64Debug(or Release)Projekt_NameAppX

我使用的代码是:

        std::wifstream fileIn(path.c_str());
        if (fileIn)
        {
            DebugPrint("The file loading begun: nn");
            while (fileIn)
            {
                wchar_t line[64];
                memset(line, '', 64);
                fileIn.getline(line, 64);
                DebugPrint(line);
                DebugPrint("n");
            }
        }
        else {
            DebugPrint("t The file wasnt loaded...n");
        }