0

Even though I have already changed the API Compatibility Level from .NET 2.0 Subset to .NET 2.0 in Edit->Project Settings->Player under Optimizations, upon upgrading to Unity 5.3.0 I am still getting the following two error messages:

`System.IO.File' does not contain a definition for `AppendText'
`System.IO.File' does not contain a definition for `CreateText'

They refer to the following code snippets:

using(StreamWriter writer = File.CreateText(saveFilePath))
{
    string sLine = "time;joint;pos_x;pos_y;poz_z";
    writer.WriteLine(sLine);
}

using(StreamWriter writer = File.AppendText(saveFilePath))
{
    string sLine = string.Format("{0:F3};{1};{2:F3};{3:F3};{4:F3}", Time.time, (int)joint, jointPos.x, jointPos.y, jointPos.z);
    writer.WriteLine(sLine);
}

How do I resolve this?

1 Answers1

0

Are you tried this case?

using (var f = new StreamWriter("file path", true))
{
    f.WriteLine("appended text");
    f.Flush();
}