In order to use the File and Directory functions, we put this at the beginning of our C# script:
#if UNITY_WINRT
using UnityEngine.Windows;
using File = UnityEngine.Windows.File;
using Directory = UnityEngine.Windows.Directory; #else
using System.IO;
using File = System.IO.File;
using Directory = System.IO.Directory; #endif
However, there are a few functions that are not supported by UnityEngine.Windows. For example: Directory.GetFiles or File.Move.
Is there a way to workaround these limitations?
Specifically asking about our most important problem to solve: Is there a way to get the list of files in a folder / directory?
You can use StorageFile and StorageFolder classes from Windows.Storage namespace.
In order to use them, the script must be compiled using .NET Core and the code with these classes wrapped with #if NETFX_CORE.
Or you can write a plugin.
There would be another solution. When you select “Use .NET Core partially”, scripts in Assets/Standard Assets, Assets/Pro Standard Assets and Assets/Plugins are compiled using Mono C# compiler, while all the others are compiled using Microsoft C# compiler. In result, JS can see classes from those three folders and you can use WinRT APIs in all other C# scripts.
No. That option just switches the compiler, which allows accessing C# classes from UnityScript and Boo. The cost of that is that these scripts can not use WinRT API.
This compilation option does not make any part of Unity API work. It might compile scripts in some cases, but they will still fail at runtime. Exception is restricted .NET APIs, which might compile and work, but they will fail certification later, so you won’t be able to submit your game to store.