System.IO.File' does not contain a definition for `AppendAllText' error in Unity3D?

拥有回忆 提交于 2019-12-05 15:13:53

I ran into this, where no one else on my team could reproduce it.

We are targeting the iOS platform, and for some reason, my Build settings changed magically back to Web Player. Changing this BACK to iOS fixed the issue for me.

On Mac, I went to File ==> Build Settings...

The "Unity" icon was next to Web Player, so I switched it to iOS and hit the "Switch Platform" button. It reimported a bunch of stuff and, when it was done, the compiler error went away.

You can try File.AppendText:

using(StreamWriter sw = File.AppendText(
          Application.persistentDataPath + "error.log"))
{
    sw.Write(e.ToString());
}

That may not be the best way to do this but it should work. I don't know if AppendAllText includes an implicit newline - doesn't appear to from the docs - but you might want .WriteLine instead.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!