Why do I get the error - 'WriteAllText' is not a member of 'System.IO.File

I am trying to create a simple text file but I’m getting the above error.

All I am doing is the following:

System.IO.File.WriteAllText("C:/Users/Simon/Desktop/exampleSaveData.txt", stringToPost);

This post is related.

Check your game target, I had the same problem. You can’t use WriteAllText if the target is the web. There doesn’t seem to be a unity stub for it either so you need to @ifdef it out on web targets.

Ok switch to standalone and not web player mode fixes it…

I just had the error happening in one script and not another with the same line.