which platform are you trying to use the code for? It will only work on Windows Store Apps, and you’ll have to wrap the code in #if NET_FX/#endif.
On other platforms, you cannot use async/.NET 4.5 code in scripts. If you want to use it for windows phone, you’ll have to write that code in separate visual studio solution and compile it to DLL, so unity can use it as a plugin.
Just the usual File.IO File.WriteAllBytes() etc. If not then it will be kind of annoying to have to write a plugin to have to use the new StorageFile classes that windows 8.1 uses just to do file io. the new StorageFile functions are all async so we need the Task to be available to use them in conjunction with Unity.
I’m trying this simplest script for (Windows Store Apps platform) to write data to a bin file but it keeps failing with the message
on the VS Simulator :-
File.WriteAllBytes - failed to open TestFile.bin for writing
#if UNITY_WINRT
using File = UnityEngine.Windows.File;
#else
using File = System.IO.File;
#endif
public class BinaryTest2 : MonoBehaviour {
// Use this for initialization
void Start () {
Debug.Log ("Creating and writing to file...");
Byte[] myData = new Byte[4] ;
File.WriteAllBytes ("TestFile.bin", myData);
}
Windows Store Apps don’t allow you to write to anywhere you want on disk, except for a few special places. I suggest you try writing the data in this folder: