XNA Game Studio-无法在项目中编辑文件

时间:2018-09-13 13:25:29

标签: c# xna

我正在Visual Studio 2017中使用 XNA Game 4.0 项目,并且在编辑文件夹中的文件时遇到问题。

我在名为debuglog.txt的文件夹中有一个名为Logs的文件。

文件夹和文件已正确添加到项目中;它们都正确显示在bin/x68/Debug目录中(debuglog.txtLogs中,而Logsbin/x68/Debug中)。

但是,当我尝试使用LoadContent方法编辑文件内容时,如下所示:

public string fileName = @"Content\Logs\debuglog.txt";
...
protected override void LoadContent(){
    //Only the relevant code is shown and this is guaranteed to run
    using(StreamWriter writer = new StreamWriter(File.Open(fileName, FileMode.OpenOrCreate))){
        writer.Write("Test");
    }
}

文件中没有“测试”。

我试图省略文件路径的Content部分,但后来也没有用。

问:为什么未将文件写入?

0 个答案:

没有答案