问题
I am very new to Unity3d and tried to open an existing project. While playing it shows the following error.
Assets/Scripts/DataAccess.cs(39,30): error CS0117: System.IO.File' does not contain a definition for
AppendAllText'
I dont have any idea about how to solve this. I get stuck over here.
It would be appreciating if anyone solve this problem.
Thanks in advance...
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/10121565/system-io-file-does-not-contain-a-definition-for-appendalltext-error-in-unity